File tree Expand file tree Collapse file tree 5 files changed +19
-7
lines changed
src/main/java/com/tc/object Expand file tree Collapse file tree 5 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 14
14
import java .io .IOException ;
15
15
16
16
public class ClientServerExchangeLockContext implements TCSerializable <ClientServerExchangeLockContext > {
17
+ private static final State [] STATE_VALUES = State .values ();
18
+
17
19
private LockID lockID ;
18
20
private NodeID nodeID ;
19
21
private ThreadID threadID ;
@@ -88,7 +90,7 @@ public ClientServerExchangeLockContext deserializeFrom(TCByteBufferInput input)
88
90
ns .deserializeFrom (input );
89
91
nodeID = ns .getNodeID ();
90
92
threadID = new ThreadID (input .readLong ());
91
- state = State . values () [input .readInt ()];
93
+ state = STATE_VALUES [input .readInt ()];
92
94
if (state .getType () == Type .WAITER || state .getType () == Type .TRY_PENDING ) {
93
95
this .timeout = input .readLong ();
94
96
} else {
Original file line number Diff line number Diff line change 11
11
import java .io .IOException ;
12
12
13
13
public class LockIDSerializer implements TCSerializable <LockIDSerializer > {
14
+ private static final LockIDType [] LOCK_ID_TYPE_VALUES = LockIDType .values ();
15
+
14
16
private LockID lockID ;
15
17
16
18
public LockIDSerializer () {
@@ -35,7 +37,7 @@ public LockIDSerializer deserializeFrom(TCByteBufferInput serialInput) throws IO
35
37
36
38
private LockID getImpl (byte type ) {
37
39
try {
38
- switch (LockIDType . values () [type ]) {
40
+ switch (LOCK_ID_TYPE_VALUES [type ]) {
39
41
case LONG :
40
42
return new LongLockID ();
41
43
case STRING :
Original file line number Diff line number Diff line change 31
31
*/
32
32
public class LockRequestMessage extends DSOMessageBase implements MultiThreadedEventContext {
33
33
34
+ private static final RequestType [] REQUEST_TYPE_VALUES = RequestType .values ();
35
+ private static final ServerLockLevel [] SERVER_LOCK_LEVEL_VALUES = ServerLockLevel .values ();
36
+
34
37
private final static byte LOCK_ID = 1 ;
35
38
private final static byte LOCK_LEVEL = 2 ;
36
39
private final static byte THREAD_ID = 3 ;
@@ -144,7 +147,7 @@ protected boolean hydrateValue(byte name) throws IOException {
144
147
return true ;
145
148
case LOCK_LEVEL :
146
149
try {
147
- lockLevel = ServerLockLevel . values () [getByteValue ()];
150
+ lockLevel = SERVER_LOCK_LEVEL_VALUES [getByteValue ()];
148
151
} catch (ArrayIndexOutOfBoundsException e ) {
149
152
return false ;
150
153
}
@@ -154,7 +157,7 @@ protected boolean hydrateValue(byte name) throws IOException {
154
157
return true ;
155
158
case REQUEST_TYPE :
156
159
try {
157
- requestType = RequestType . values () [getByteValue ()];
160
+ requestType = REQUEST_TYPE_VALUES [getByteValue ()];
158
161
} catch (ArrayIndexOutOfBoundsException e ) {
159
162
return false ;
160
163
}
Original file line number Diff line number Diff line change 22
22
23
23
public class LockResponseMessage extends DSOMessageBase implements MultiThreadedEventContext {
24
24
25
+ private static final ServerLockLevel [] SERVER_LOCK_LEVEL_VALUES = ServerLockLevel .values ();
26
+ private static final ResponseType [] RESPONSE_TYPE_VALUES = ResponseType .values ();
27
+
25
28
private static final byte TYPE = 1 ;
26
29
private static final byte THREAD_ID = 2 ;
27
30
private static final byte LOCK_ID = 3 ;
@@ -97,7 +100,7 @@ protected boolean hydrateValue(byte name) throws IOException {
97
100
switch (name ) {
98
101
case TYPE :
99
102
try {
100
- responseType = ResponseType . values () [getByteValue ()];
103
+ responseType = RESPONSE_TYPE_VALUES [getByteValue ()];
101
104
} catch (ArrayIndexOutOfBoundsException e ) {
102
105
return false ;
103
106
}
@@ -112,7 +115,7 @@ protected boolean hydrateValue(byte name) throws IOException {
112
115
return true ;
113
116
case LOCK_LEVEL :
114
117
try {
115
- lockLevel = ServerLockLevel . values () [getByteValue ()];
118
+ lockLevel = SERVER_LOCK_LEVEL_VALUES [getByteValue ()];
116
119
} catch (ArrayIndexOutOfBoundsException e ) {
117
120
return false ;
118
121
}
Original file line number Diff line number Diff line change 19
19
*/
20
20
class ServerEventSerializableContext implements TCSerializable <ServerEventSerializableContext > {
21
21
22
+ private static final ServerEventType [] SERVER_EVENT_TYPE_VALUES = ServerEventType .values ();
23
+
22
24
private static final DNAEncoding serializer = new SerializerDNAEncodingImpl ();
23
25
24
26
private ServerEvent event ;
@@ -54,7 +56,7 @@ public void serializeTo(final TCByteBufferOutput out) {
54
56
public ServerEventSerializableContext deserializeFrom (TCByteBufferInput in ) throws IOException {
55
57
try {
56
58
int index = (Integer ) serializer .decode (in );
57
- final ServerEventType type = ServerEventType . values () [index ];
59
+ final ServerEventType type = SERVER_EVENT_TYPE_VALUES [index ];
58
60
final String destination = (String ) serializer .decode (in );
59
61
final Object key = serializer .decode (in );
60
62
final byte [] value = (byte []) serializer .decode (in );
You can’t perform that action at this time.
0 commit comments