Skip to content

Commit dd506c6

Browse files
committed
core: Undo stateid4.forBytes change
... to reduce the amount of changes in #162 Signed-off-by: Christian Kohlschütter <[email protected]>
1 parent db14099 commit dd506c6

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

core/src/main/java/org/dcache/nfs/v4/NFSv4StateHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ public stateid4 createStateId(NFS4Client client, byte type, int count) {
481481
// we eat the first 8 bits if the counter, however, we don't expect 16M states be active at the same time,
482482
// thus the probability of a collision is too low
483483
Bytes.putInt(other, 8, count << 8 | (type & 0xFF));
484-
return stateid4.forBytes(other, STATE_INITIAL_SEQUENCE);
484+
return new stateid4(other, STATE_INITIAL_SEQUENCE);
485485
}
486486

487487
/**

core/src/main/java/org/dcache/nfs/v4/Stateids.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ private Stateids() {
5656
}
5757

5858
private final static stateid4 CURRENT_STATEID =
59-
stateid4.forBytes(new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1);
59+
new stateid4(new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1);
6060
private final static stateid4 INVAL_STATEID =
61-
stateid4.forBytes(new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, nfs4_prot.NFS4_UINT32_MAX);
61+
new stateid4(new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, nfs4_prot.NFS4_UINT32_MAX);
6262
private final static stateid4 ZERO_STATEID =
63-
stateid4.forBytes(new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0);
63+
new stateid4(new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0);
6464

65-
private final static stateid4 ONE_STATEID = stateid4.forBytes(new byte[] {
65+
private final static stateid4 ONE_STATEID = new stateid4(new byte[] {
6666
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
6767
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}, nfs4_prot.NFS4_UINT32_MAX);
6868

6969
public static stateid4 uptodateOf(stateid4 stateid) {
70-
return stateid4.forBytes(stateid.getOpaque().toBytes(), 0);
70+
return new stateid4(stateid.getOpaque().toBytes(), 0);
7171
}
7272

7373
public static stateid4 currentStateId() {

core/src/main/java/org/dcache/nfs/v4/xdr/stateid4.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,11 @@ public class stateid4 implements XdrAble, Serializable, Cloneable {
3939
private byte[] other; // only declared for Java Serialization
4040
private transient Opaque opaque;
4141

42-
public static stateid4 forBytes(byte[] bytes, int seqid) {
43-
return new stateid4(seqid, Opaque.forBytes(bytes));
44-
}
45-
4642
public stateid4(XdrDecodingStream xdr) throws OncRpcException, IOException {
4743
this.seqid = xdr.xdrDecodeInt();
4844
this.opaque = Opaque.forBytes(xdr.xdrDecodeOpaque(12));
4945
}
5046

51-
@Deprecated(forRemoval = true)
5247
public stateid4(byte[] bytes, int seqid) {
5348
this(seqid, Opaque.forBytes(bytes));
5449
}

core/src/test/java/org/dcache/nfs/v4/xdr/stateid4Test.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public class stateid4Test {
2929
@Test
3030
public void testEqualsTrue() {
3131

32-
stateid4 stateidA = stateid4.forBytes("state".getBytes(), 1);
32+
stateid4 stateidA = new stateid4("state".getBytes(), 1);
3333

34-
stateid4 stateidB = stateid4.forBytes("state".getBytes(), 1);
34+
stateid4 stateidB = new stateid4("state".getBytes(), 1);
3535

3636
assertTrue("equal keys not equal", stateidA.equals(stateidB));
3737
assertTrue("equal, but different hashCode", stateidA.hashCode() == stateidB.hashCode());
@@ -41,17 +41,17 @@ public void testEqualsTrue() {
4141
@Test
4242
public void testEqualsSame() {
4343

44-
stateid4 stateidA = stateid4.forBytes("state".getBytes(), 1);
44+
stateid4 stateidA = new stateid4("state".getBytes(), 1);
4545

4646
assertTrue("equal keys not equal", stateidA.equals(stateidA));
4747
}
4848

4949
@Test
5050
public void testDifferSequence() {
5151

52-
stateid4 stateidA = stateid4.forBytes("state".getBytes(), 1);
52+
stateid4 stateidA = new stateid4("state".getBytes(), 1);
5353

54-
stateid4 stateidB = stateid4.forBytes("state".getBytes(), 2);
54+
stateid4 stateidB = new stateid4("state".getBytes(), 2);
5555

5656
assertTrue("differ by sequence should still be equal", stateidA.equals(stateidB));
5757
assertFalse("differ by sequence can't be equal", stateidA.equalsWithSeq(stateidB));
@@ -60,9 +60,9 @@ public void testDifferSequence() {
6060
@Test
6161
public void testDifferOther() {
6262

63-
stateid4 stateidA = stateid4.forBytes("stateA".getBytes(), 1);
63+
stateid4 stateidA = new stateid4("stateA".getBytes(), 1);
6464

65-
stateid4 stateidB = stateid4.forBytes("stateB".getBytes(), 1);
65+
stateid4 stateidB = new stateid4("stateB".getBytes(), 1);
6666

6767
assertFalse("differ by other not detected", stateidA.equals(stateidB));
6868
}

0 commit comments

Comments
 (0)