Skip to content

Commit 54a8417

Browse files
junghoon-vansjhpark816
authored andcommitted
INTERNAL: Use isEmpty method to simplify empty checking
1 parent d137df2 commit 54a8417

13 files changed

+21
-21
lines changed

src/main/java/net/spy/memcached/ArcusClient.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2305,7 +2305,7 @@ public List<SMGetTrimKey> getTrimmedKeys() {
23052305

23062306
@Override
23072307
public CollectionOperationStatus getOperationStatus() {
2308-
if (failedOperationStatus.size() > 0) {
2308+
if (!failedOperationStatus.isEmpty()) {
23092309
return new CollectionOperationStatus(failedOperationStatus.get(0));
23102310
}
23112311
return new CollectionOperationStatus(resultOperationStatus.get(0));
@@ -2564,7 +2564,7 @@ public List<SMGetTrimKey> getTrimmedKeys() {
25642564

25652565
@Override
25662566
public CollectionOperationStatus getOperationStatus() {
2567-
if (failedOperationStatus.size() > 0) {
2567+
if (!failedOperationStatus.isEmpty()) {
25682568
return new CollectionOperationStatus(failedOperationStatus.get(0));
25692569
}
25702570
return new CollectionOperationStatus(resultOperationStatus.get(0));

src/main/java/net/spy/memcached/ArcusKetamaNodeLocator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ private void removeHash(MemcachedNode node) {
301301
SortedSet<MemcachedNode> nodeSet = ketamaNodes.get(k);
302302
assert nodeSet != null;
303303
nodeSet.remove(node);
304-
if (nodeSet.size() == 0) {
304+
if (nodeSet.isEmpty()) {
305305
ketamaNodes.remove(k);
306306
}
307307
}
@@ -338,7 +338,7 @@ private void insertHashOfJOIN(MemcachedNode node) {
338338
Long k = getKetamaHashPoint(digest, h);
339339
SortedSet<MemcachedNode> alterSet = ketamaAlterNodes.get(k);
340340
if (alterSet != null && alterSet.remove(node)) {
341-
if (alterSet.size() == 0) {
341+
if (alterSet.isEmpty()) {
342342
ketamaAlterNodes.remove(k);
343343
}
344344
SortedSet<MemcachedNode> existSet = ketamaNodes.get(k);

src/main/java/net/spy/memcached/ArcusReplKetamaNodeLocator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ private void removeHash(MemcachedReplicaGroup group) {
410410
Long k = getKetamaHashPoint(digest, h);
411411
SortedSet<MemcachedReplicaGroup> nodeSet = ketamaGroups.get(k);
412412
nodeSet.remove(group);
413-
if (nodeSet.size() == 0) {
413+
if (nodeSet.isEmpty()) {
414414
ketamaGroups.remove(k);
415415
}
416416
}
@@ -444,7 +444,7 @@ private void insertHashOfJOIN(MemcachedReplicaGroup group) {
444444
Long k = getKetamaHashPoint(digest, h);
445445
SortedSet<MemcachedReplicaGroup> alterSet = ketamaAlterGroups.get(k);
446446
if (alterSet != null && alterSet.remove(group)) {
447-
if (alterSet.size() == 0) {
447+
if (alterSet.isEmpty()) {
448448
ketamaAlterGroups.remove(k);
449449
}
450450
SortedSet<MemcachedReplicaGroup> existSet = ketamaGroups.get(k);

src/main/java/net/spy/memcached/CacheManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ private String getAddressListString(List<String> children) {
439439
* @param children new children node list
440440
*/
441441
public void commandCacheListChange(List<String> children) {
442-
if (children.size() == 0) {
442+
if (children.isEmpty()) {
443443
getLogger().error("Cannot find any cache nodes for your service code. " +
444444
"Please contact Arcus support to solve this problem. " +
445445
"[serviceCode=" + serviceCode + ", adminSessionId=0x" +
@@ -493,7 +493,7 @@ public void setReadingCacheList(boolean reading) {
493493
@Override
494494
public boolean commandCloudStatChange(List<String> children) {
495495
// return true if STATE == PREPARED.
496-
if (children.size() == 0) {
496+
if (children.isEmpty()) {
497497
/*
498498
* case 1 : No child znode in clout_stat znode.
499499
* case 2 : Starting migration.

src/main/java/net/spy/memcached/collection/ElementMultiFlagsFilter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public ElementMultiFlagsFilter addCompValue(byte[] compValue) {
6767
+ MAX_EFLAGS);
6868
}
6969

70-
if (this.compValue.size() > 0
70+
if (!this.compValue.isEmpty()
7171
&& this.compValue.get(0).length != compValue.length) {
7272
throw new IllegalArgumentException(
7373
"Length of comparison value must be same with "

src/main/java/net/spy/memcached/collection/MapDelete.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public String stringify() {
6666
return str;
6767
}
6868

69-
if (mkeyList.size() == 0) {
69+
if (mkeyList.isEmpty()) {
7070
additionalArgs = null;
7171
} else {
7272
additionalArgs = getSpaceSeparatedMkeys().getBytes();

src/main/java/net/spy/memcached/collection/MapGet.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public String stringify() {
6767
return str;
6868
}
6969

70-
if (mkeyList.size() == 0) {
70+
if (mkeyList.isEmpty()) {
7171
additionalArgs = null;
7272
} else {
7373
additionalArgs = getSpaceSeparatedMkeys().getBytes();

src/main/java/net/spy/memcached/internal/BroadcastFuture.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public T get(long duration, TimeUnit units)
6565
MemcachedConnection.opSucceeded(op);
6666
}
6767
}
68-
if (timedoutOps.size() > 0) {
68+
if (!timedoutOps.isEmpty()) {
6969
throw new CheckedOperationTimeoutException(duration, units, timedoutOps);
7070
}
7171
} else {

src/main/java/net/spy/memcached/internal/BulkGetFuture.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Map<String, T> getSome(long duration, TimeUnit units)
8686
throws InterruptedException, ExecutionException {
8787
Collection<Operation> timedoutOps = new HashSet<Operation>();
8888
Map<String, T> ret = internalGet(duration, units, timedoutOps);
89-
if (timedoutOps.size() > 0) {
89+
if (!timedoutOps.isEmpty()) {
9090
isTimeout = true;
9191
LoggerFactory.getLogger(getClass()).warn(
9292
new CheckedOperationTimeoutException(duration, units, timedoutOps).getMessage());
@@ -106,7 +106,7 @@ public Map<String, T> get(long duration, TimeUnit units)
106106
throws InterruptedException, ExecutionException, TimeoutException {
107107
Collection<Operation> timedoutOps = new HashSet<Operation>();
108108
Map<String, T> ret = internalGet(duration, units, timedoutOps);
109-
if (timedoutOps.size() > 0) {
109+
if (!timedoutOps.isEmpty()) {
110110
isTimeout = true;
111111
throw new CheckedOperationTimeoutException(duration, units, timedoutOps);
112112
}
@@ -148,7 +148,7 @@ private Map<String, T> internalGet(long to, TimeUnit unit,
148148
MemcachedConnection.opSucceeded(op);
149149
}
150150
}
151-
if (timedoutOps.size() > 0) {
151+
if (!timedoutOps.isEmpty()) {
152152
MemcachedConnection.opsTimedOut(timedoutOps);
153153
}
154154
} else {

src/main/java/net/spy/memcached/internal/BulkOperationFuture.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public Map<String, T> get(long duration,
7878
MemcachedConnection.opSucceeded(op);
7979
}
8080
}
81-
if (timedoutOps.size() > 0) {
81+
if (!timedoutOps.isEmpty()) {
8282
MemcachedConnection.opsTimedOut(timedoutOps);
8383
throw new CheckedOperationTimeoutException(duration, units, timedoutOps);
8484
}

src/main/java/net/spy/memcached/internal/CollectionGetBulkFuture.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public T get(long duration, TimeUnit units)
6868
MemcachedConnection.opSucceeded(op);
6969
}
7070
}
71-
if (timedoutOps.size() > 0) {
71+
if (!timedoutOps.isEmpty()) {
7272
MemcachedConnection.opsTimedOut(timedoutOps);
7373
throw new CheckedOperationTimeoutException(duration, units, timedoutOps);
7474
}

src/main/java/net/spy/memcached/internal/PipedCollectionFuture.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Map<K, V> get(long duration, TimeUnit units)
7373
MemcachedConnection.opSucceeded(op);
7474
}
7575
}
76-
if (timedoutOps.size() > 0) {
76+
if (!timedoutOps.isEmpty()) {
7777
MemcachedConnection.opTimedOut(timedoutOps.iterator().next());
7878
throw new CheckedOperationTimeoutException(duration, units, timedoutOps);
7979
}

src/main/java/net/spy/memcached/protocol/TCPMemcachedNodeImpl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ public final void fixupOps() {
626626
}
627627

628628
public final void authComplete() {
629-
if (reconnectBlocked != null && reconnectBlocked.size() > 0) {
629+
if (reconnectBlocked != null && !reconnectBlocked.isEmpty()) {
630630
inputQueue.addAll(reconnectBlocked);
631631
}
632632
authLatch.countDown();
@@ -635,12 +635,12 @@ public final void authComplete() {
635635
public final void setupForAuth(String cause) {
636636
if (shouldAuth) {
637637
authLatch = new CountDownLatch(1);
638-
if (inputQueue.size() > 0) {
638+
if (!inputQueue.isEmpty()) {
639639
reconnectBlocked = new ArrayList<Operation>(
640640
inputQueue.size() + 1);
641641
inputQueue.drainTo(reconnectBlocked);
642642
}
643-
assert (inputQueue.size() == 0);
643+
assert (inputQueue.isEmpty());
644644
setupResend(cause);
645645
} else {
646646
authLatch = new CountDownLatch(0);

0 commit comments

Comments
 (0)