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

Code Improvements: %n should be used, Collection.isEmpty() should be used #35

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 @@ -77,7 +77,7 @@ public synchronized void log(Level level, Object message, Throwable e) {
|| level == Level.WARN
|| level == Level.ERROR
|| level == Level.FATAL) {
System.err.printf("%s %s %s: %s\n", df.format(new Date()), level.name(),
System.err.printf("%s %s %s: %s%n", df.format(new Date()), level.name(),
getName(), message);
if (e != null) {
e.printStackTrace();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/spy/memcached/internal/BulkGetFuture.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Map<String, T> getSome(long to, TimeUnit unit)
throws InterruptedException, ExecutionException {
Collection<Operation> timedoutOps = new HashSet<Operation>();
Map<String, T> ret = internalGet(to, unit, timedoutOps);
if (timedoutOps.size() > 0) {
if (!timedoutOps.isEmpty()) {
timeout = true;
LoggerFactory.getLogger(getClass()).warn(
new CheckedOperationTimeoutException("Operation timed out: ",
Expand All @@ -122,7 +122,7 @@ public Map<String, T> get(long to, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
Collection<Operation> timedoutOps = new HashSet<Operation>();
Map<String, T> ret = internalGet(to, unit, timedoutOps);
if (timedoutOps.size() > 0) {
if (!timedoutOps.isEmpty()) {
this.timeout = true;
throw new CheckedOperationTimeoutException("Operation timed out.",
timedoutOps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ public final void fixupOps() {
}

public final void authComplete() {
if (reconnectBlocked != null && reconnectBlocked.size() > 0) {
if (reconnectBlocked != null && !reconnectBlocked.isEmpty()) {
inputQueue.addAll(reconnectBlocked);
}
authLatch.countDown();
Expand All @@ -620,11 +620,11 @@ public final void authComplete() {
public final void setupForAuth() {
if (shouldAuth) {
authLatch = new CountDownLatch(1);
if (inputQueue.size() > 0) {
if (!inputQueue.isEmpty()) {
reconnectBlocked = new ArrayList<Operation>(inputQueue.size() + 1);
inputQueue.drainTo(reconnectBlocked);
}
assert (inputQueue.size() == 0);
assert (inputQueue.isEmpty());
setupResend();
} else {
authLatch = new CountDownLatch(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected void finishedPayload(byte[] pl) throws IOException {
getStatusForErrorCode(errorCode, pl);

if (responseOpaque == terminalOpaque) {
if (retryKeys.size() > 0) {
if (!retryKeys.isEmpty()) {
transitionState(OperationState.RETRY);
OperationStatus retryStatus = new OperationStatus(true,
Integer.toString(retryKeys.size()), StatusCode.ERR_NOT_MY_VBUCKET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public ByteBuffer getBytes() {

@Override
public String toString() {
return String.format("Key: %s, Flags: %d, TTL: %d, Size: %d\nValue: %s",
return String.format("Key: %s, Flags: %d, TTL: %d, Size: %d%nValue: %s",
getKey(), getItemFlags(), getTTL(), getValue().length, deserialize());
}

Expand Down