20
20
package org .dcache .nfs .v4 .xdr ;
21
21
22
22
import java .io .IOException ;
23
+ import java .io .ObjectInputStream .GetField ;
24
+ import java .io .ObjectOutputStream .PutField ;
23
25
import java .io .Serializable ;
24
26
25
27
import org .dcache .nfs .util .Opaque ;
@@ -33,15 +35,17 @@ public class stateid4 implements XdrAble, Serializable, Cloneable {
33
35
static final long serialVersionUID = -6677150504723505919L ;
34
36
35
37
private int seqid ;
36
- private final Opaque other ;
38
+ @ SuppressWarnings ("unused" )
39
+ private byte [] other ; // only declared for Java Serialization
40
+ private transient Opaque opaque ;
37
41
38
42
public static stateid4 forBytes (byte [] bytes , int seqid ) {
39
43
return new stateid4 (seqid , Opaque .forBytes (bytes ));
40
44
}
41
45
42
46
public stateid4 (XdrDecodingStream xdr ) throws OncRpcException , IOException {
43
47
this .seqid = xdr .xdrDecodeInt ();
44
- this .other = Opaque .forBytes (xdr .xdrDecodeOpaque (12 ));
48
+ this .opaque = Opaque .forBytes (xdr .xdrDecodeOpaque (12 ));
45
49
}
46
50
47
51
@ Deprecated (forRemoval = true )
@@ -51,38 +55,38 @@ public stateid4(byte[] bytes, int seqid) {
51
55
52
56
private stateid4 (int seqid , Opaque other ) {
53
57
this .seqid = seqid ;
54
- this .other = other .toImmutableOpaque ();
58
+ this .opaque = other .toImmutableOpaque ();
55
59
}
56
60
57
61
public Opaque getOpaque () {
58
- return other ;
62
+ return opaque ;
59
63
}
60
64
61
65
public int getSeqId () {
62
66
return seqid ;
63
67
}
64
68
65
69
public long getClientId () {
66
- return other .longAt (0 );
70
+ return opaque .longAt (0 );
67
71
}
68
72
69
73
public static long getClientId (Opaque stateIdOther ) {
70
74
return stateIdOther .longAt (0 );
71
75
}
72
76
73
77
public int getType () {
74
- return other .byteAt (11 );
78
+ return opaque .byteAt (11 );
75
79
}
76
80
77
81
@ Override
78
82
public stateid4 clone () {
79
- return new stateid4 (seqid , other );
83
+ return new stateid4 (seqid , opaque );
80
84
}
81
85
82
86
public void xdrEncode (XdrEncodingStream xdr )
83
87
throws OncRpcException , IOException {
84
88
xdr .xdrEncodeInt (seqid );
85
- xdr .xdrEncodeOpaque (other .toBytes (), 12 );
89
+ xdr .xdrEncodeOpaque (opaque .toBytes (), 12 );
86
90
}
87
91
88
92
public void xdrDecode (XdrDecodingStream xdr )
@@ -100,7 +104,7 @@ public boolean equals(Object obj) {
100
104
101
105
final stateid4 other_id = (stateid4 ) obj ;
102
106
103
- return this .other .equals (other_id .other );
107
+ return this .opaque .equals (other_id .opaque );
104
108
}
105
109
106
110
/**
@@ -115,26 +119,41 @@ public boolean equalsWithSeq(stateid4 otherState) {
115
119
return true ;
116
120
}
117
121
118
- return otherState .seqid == this .seqid && this .other .equals (otherState .other );
122
+ return otherState .seqid == this .seqid && this .opaque .equals (otherState .opaque );
119
123
}
120
124
121
125
@ Override
122
126
public int hashCode () {
123
- return this .other .hashCode ();
127
+ return this .opaque .hashCode ();
124
128
}
125
129
126
130
@ Override
127
131
public String toString () {
128
132
StringBuilder sb = new StringBuilder ();
129
133
130
134
sb .append ("[" );
131
- sb .append (other );
135
+ sb .append (opaque );
132
136
sb .append (", seq: " ).append (seqid ).append ("]" );
133
137
return sb .toString ();
134
138
}
135
139
136
140
public void bumpSeqid () {
137
141
++seqid ;
138
142
}
143
+
144
+ private void writeObject (java .io .ObjectOutputStream out )
145
+ throws IOException {
146
+ PutField pf = out .putFields ();
147
+ pf .put ("seqid" , this .seqid );
148
+ pf .put ("other" , this .opaque .toBytes ());
149
+ out .writeFields ();
150
+ }
151
+
152
+ private void readObject (java .io .ObjectInputStream in )
153
+ throws IOException , ClassNotFoundException {
154
+ GetField gf = in .readFields ();
155
+ this .seqid = gf .get ("seqid" , 0 );
156
+ this .opaque = Opaque .forBytes ((byte []) gf .get ("other" , new byte [0 ]));
157
+ }
139
158
}
140
159
// End of stateid4.java
0 commit comments