Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

squid:S1698 Object should be compared with equals() #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public MetricCollector getMetricCollector() {
}

String enableMetrics = System.getProperty("net.spy.metrics.enable");
if (enableMetrics().equals(MetricType.OFF) || enableMetrics == "false") {
if (MetricType.OFF.equals(enableMetrics()) || "false".equals(enableMetrics)) {
getLogger().debug("Metric collection disabled.");
metrics = new NoopMetricCollector();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/spy/memcached/KetamaNodeLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected void setKetamaNodes(List<MemcachedNode> nodes) {
int numReps = config.getNodeRepetitions();
for (MemcachedNode node : nodes) {
// Ketama does some special work with md5 where it reuses chunks.
if (hashAlg == DefaultHashAlgorithm.KETAMA_HASH) {
if (DefaultHashAlgorithm.KETAMA_HASH.equals(hashAlg)) {
for (int i = 0; i < numReps / 4; i++) {
byte[] digest =
DefaultHashAlgorithm.computeMd5(config.getKeyForNode(node, i));
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/spy/memcached/MemcachedConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ private void readBufferAndLogMetrics(final Operation currentOp,
getLogger().debug("Completed read op: %s and giving the next %d "
+ "bytes", currentOp, rbuf.remaining());
Operation op = node.removeCurrentReadOp();
assert op == currentOp : "Expected to pop " + currentOp + " got "
assert op.equals(currentOp) : "Expected to pop " + currentOp + " got "
+ op;

if (op.hasErrored()) {
Expand All @@ -878,7 +878,7 @@ private void readBufferAndLogMetrics(final Operation currentOp,
((VBucketAware) currentOp).addNotMyVbucketNode(
currentOp.getHandlingNode());
Operation op = node.removeCurrentReadOp();
assert op == currentOp : "Expected to pop " + currentOp + " got "
assert op.equals(currentOp) : "Expected to pop " + currentOp + " got "
+ op;

retryOps.add(currentOp);
Expand All @@ -905,7 +905,7 @@ private Operation handleReadsWhenChannelEndOfStream(final Operation currentOp,
getLogger().debug("Completed read op: %s and giving the next %d bytes",
currentOp, rbuf.remaining());
Operation op = node.removeCurrentReadOp();
assert op == currentOp : "Expected to pop " + currentOp + " got " + op;
assert op.equals(currentOp) : "Expected to pop " + currentOp + " got " + op;
return node.getCurrentReadOp();
} else {
throw new IOException("Disconnected unexpected, will reconnect.");
Expand Down Expand Up @@ -1126,7 +1126,7 @@ private void attemptReconnects() {
ops = SelectionKey.OP_CONNECT;
}
node.registerChannel(ch, ch.register(selector, ops, node));
assert node.getChannel() == ch : "Channel was lost.";
assert node.getChannel().equals(ch) : "Channel was lost.";
} else {
getLogger().debug("Skipping duplicate reconnect request for %s",
node);
Expand Down Expand Up @@ -1247,7 +1247,7 @@ public void insertOperation(final MemcachedNode node, final Operation o) {
metrics.markMeter(OVERALL_REQUEST_METRIC);

Selector s = selector.wakeup();
assert s == selector : "Wakeup returned the wrong selector.";
assert s.equals(selector) : "Wakeup returned the wrong selector.";
getLogger().debug("Added %s to %s", o, node);
}

Expand All @@ -1269,7 +1269,7 @@ protected void addOperation(final MemcachedNode node, final Operation o) {
metrics.markMeter(OVERALL_REQUEST_METRIC);

Selector s = selector.wakeup();
assert s == selector : "Wakeup returned the wrong selector.";
assert s.equals(selector) : "Wakeup returned the wrong selector.";
getLogger().debug("Added %s to %s", o, node);
}

Expand Down Expand Up @@ -1315,7 +1315,7 @@ public CountDownLatch broadcastOperation(final BroadcastOpFactory of,
}

Selector s = selector.wakeup();
assert s == selector : "Wakeup returned the wrong selector.";
assert s.equals(selector) : "Wakeup returned the wrong selector.";
return latch;
}

Expand All @@ -1326,7 +1326,7 @@ public void shutdown() throws IOException {
shutDown = true;
try {
Selector s = selector.wakeup();
assert s == selector : "Wakeup returned the wrong selector.";
assert s.equals(selector) : "Wakeup returned the wrong selector.";
for (MemcachedNode node : locator.getAll()) {
if (node.getChannel() != null) {
node.getChannel().close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public final void setupResend() {
// to requeue them.
while (hasReadOp()) {
op = removeCurrentReadOp();
if (op != getCurrentWriteOp()) {
if (!op.equals(getCurrentWriteOp())) {
getLogger().warn("Discarding partially completed op: %s", op);
op.cancel();
}
Expand Down Expand Up @@ -240,11 +240,11 @@ private Operation getNextWritableOp() {
if (o.isCancelled()) {
getLogger().debug("Not writing cancelled op.");
Operation cancelledOp = removeCurrentWriteOp();
assert o == cancelledOp;
assert o.equals(cancelledOp);
} else if (o.isTimedOut(defaultOpTimeout)) {
getLogger().debug("Not writing timed out op.");
Operation timedOutOp = removeCurrentWriteOp();
assert o == timedOutOp;
assert o.equals(timedOutOp);
} else {
o.writing();
if (!(o instanceof TapAckOperationImpl)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ protected void prepareBuffer(final String key, final long cas,
int bufSize = MIN_RECV_PACKET + keyBytes.length + val.length;

ByteBuffer bb = ByteBuffer.allocate(bufSize + extraLen);
assert bb.order() == ByteOrder.BIG_ENDIAN;
assert ByteOrder.BIG_ENDIAN.equals(bb.order());
bb.put(REQ_MAGIC);
bb.put(cmd);
bb.putShort((short) keyBytes.length);
Expand Down