From 320227e09a34b807850d15dcb9d6aad737bb34eb Mon Sep 17 00:00:00 2001 From: Zeeshan Asghar Date: Sat, 16 Jan 2016 18:29:01 +0500 Subject: [PATCH] squid:S2864 entrySet() should be iterated when both key and value are needed findbugs:DM_NUMBER_CTOR Performance-Method invokes inefficient Number constructor; use static valueOf instead pm:UnnecessaryConstructor Remove all unnecessary constructor --- src/main/java/net/spy/memcached/MemcachedClient.java | 4 ++-- src/main/java/net/spy/memcached/compat/SpyObject.java | 7 ------- .../memcached/protocol/binary/MultiGetOperationImpl.java | 2 +- .../java/net/spy/memcached/tapmessage/RequestMessage.java | 6 +++--- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/spy/memcached/MemcachedClient.java b/src/main/java/net/spy/memcached/MemcachedClient.java index 9d376d13a..fac286a3e 100644 --- a/src/main/java/net/spy/memcached/MemcachedClient.java +++ b/src/main/java/net/spy/memcached/MemcachedClient.java @@ -1758,7 +1758,7 @@ public void receivedStatus(OperationStatus s) { // XXX: Potential abstraction leak. // The handling of incr/decr in the binary protocol // Allows us to avoid string processing. - rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1")); + rv.set(Long.valueOf(s.isSuccess() ? s.getMessage() : "-1")); } @Override @@ -1993,7 +1993,7 @@ private OperationFuture asyncMutate(Mutator m, String key, long by, new OperationCallback() { @Override public void receivedStatus(OperationStatus s) { - rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"), s); + rv.set(Long.valueOf(s.isSuccess() ? s.getMessage() : "-1"), s); } @Override diff --git a/src/main/java/net/spy/memcached/compat/SpyObject.java b/src/main/java/net/spy/memcached/compat/SpyObject.java index 0c4e0d251..778f2da0b 100644 --- a/src/main/java/net/spy/memcached/compat/SpyObject.java +++ b/src/main/java/net/spy/memcached/compat/SpyObject.java @@ -32,13 +32,6 @@ public class SpyObject extends Object { private transient Logger logger = null; - /** - * Get an instance of SpyObject. - */ - public SpyObject() { - super(); - } - /** * Get a Logger instance for this class. * diff --git a/src/main/java/net/spy/memcached/protocol/binary/MultiGetOperationImpl.java b/src/main/java/net/spy/memcached/protocol/binary/MultiGetOperationImpl.java index bc1f848cf..1f8a11d7f 100644 --- a/src/main/java/net/spy/memcached/protocol/binary/MultiGetOperationImpl.java +++ b/src/main/java/net/spy/memcached/protocol/binary/MultiGetOperationImpl.java @@ -72,7 +72,7 @@ protected int addKey(String k) { bkeys.put(rv, KeyUtil.getKeyBytes(k)); rkeys.put(k, rv); synchronized (vbmap) { - vbmap.put(k, new Short((short) 0)); + vbmap.put(k, Short.valueOf((short) 0)); } } return rv; diff --git a/src/main/java/net/spy/memcached/tapmessage/RequestMessage.java b/src/main/java/net/spy/memcached/tapmessage/RequestMessage.java index de2863391..da6b2d99a 100644 --- a/src/main/java/net/spy/memcached/tapmessage/RequestMessage.java +++ b/src/main/java/net/spy/memcached/tapmessage/RequestMessage.java @@ -179,9 +179,9 @@ public ByteBuffer getBytes() { } if (hasVBucketCheckpoints) { bb.putShort((short)vBucketCheckpoints.size()); - for (Short vBucket : vBucketCheckpoints.keySet()) { - bb.putShort(vBucket); - bb.putLong(vBucketCheckpoints.get(vBucket)); + for (Map.Entry vBucket : vBucketCheckpoints.entrySet()){ + bb.putShort(vBucket.getKey()); + bb.putLong(vBucket.getValue()); } }