Code-inspection fixes

Motivation:

Saw some code-inspection warnings

Modifications:

Fix warnings

Result:

Less code-inspection warnings
This commit is contained in:
Norman Maurer 2014-08-21 07:20:00 +02:00
parent ceaab70153
commit 16a8f8b5aa
4 changed files with 18 additions and 20 deletions

View File

@ -112,7 +112,8 @@ public class IntObjectHashMap<V> implements IntObjectMap<V>, Iterable<IntObjectM
values[index] = toInternal(value);
growSize();
return null;
} else if (keys[index] == key) {
}
if (keys[index] == key) {
// Found existing entry with this key, just replace the value.
V previousValue = values[index];
values[index] = toInternal(value);
@ -246,7 +247,7 @@ public class IntObjectHashMap<V> implements IntObjectMap<V>, Iterable<IntObjectM
// of terms, only their values; since the map is an unordered collection and
// entries can end up in different positions in different maps that have the same
// elements, but with different history of puts/removes, due to conflicts.
hash = hash ^ keys[i];
hash ^= keys[i];
}
return hash;
}
@ -255,7 +256,8 @@ public class IntObjectHashMap<V> implements IntObjectMap<V>, Iterable<IntObjectM
public boolean equals(Object obj) {
if (this == obj) {
return true;
} else if (!(obj instanceof IntObjectMap)) {
}
if (!(obj instanceof IntObjectMap)) {
return false;
}
@SuppressWarnings("rawtypes")
@ -294,7 +296,8 @@ public class IntObjectHashMap<V> implements IntObjectMap<V>, Iterable<IntObjectM
if (values[index] == null) {
// It's available, so no chance that this value exists anywhere in the map.
return -1;
} else if (key == keys[index]) {
}
if (key == keys[index]) {
return index;
}

View File

@ -49,7 +49,7 @@ public final class DefaultExecutorFactory implements ExecutorFactory {
InternalLoggerFactory.getInstance(DefaultExecutorFactory.class);
private static final AtomicInteger executorId = new AtomicInteger();
private String namePrefix;
private final String namePrefix;
/**
* @param clazzNamePrefix the name of the class will be used to prefix the name of each
@ -69,7 +69,7 @@ public final class DefaultExecutorFactory implements ExecutorFactory {
@Override
public Executor newExecutor(int parallelism) {
ForkJoinWorkerThreadFactory threadFactory =
new DefaultForkJoinWorkerThreadFactory(namePrefix + "-" + executorId.getAndIncrement());
new DefaultForkJoinWorkerThreadFactory(namePrefix + '-' + executorId.getAndIncrement());
return new ForkJoinPool(parallelism, threadFactory, DefaultUncaughtExceptionHandler.INSTANCE, true);
}
@ -119,7 +119,7 @@ public final class DefaultExecutorFactory implements ExecutorFactory {
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
// Note: The ForkJoinPool will create these threads as daemon threads.
ForkJoinWorkerThread thread = new DefaultForkJoinWorkerThread(pool);
thread.setName(namePrefix + "-" + idx.getAndIncrement());
thread.setName(namePrefix + '-' + idx.getAndIncrement());
thread.setPriority(Thread.MAX_PRIORITY);
return thread;
}

View File

@ -64,11 +64,6 @@ final class ScheduledFutureTask<V> extends PromiseTask<V> implements ScheduledFu
periodNanos = 0;
}
@Override
protected EventExecutor executor() {
return executor;
}
public long deadlineNanos() {
return deadlineNanos;
}
@ -174,8 +169,8 @@ final class ScheduledFutureTask<V> extends PromiseTask<V> implements ScheduledFu
*/
private boolean needsLaterExecution() {
return task instanceof CallableEventExecutorAdapter &&
((CallableEventExecutorAdapter) task).executor() instanceof PausableEventExecutor &&
!((PausableEventExecutor) ((CallableEventExecutorAdapter) task).executor()).isAcceptingNewTasks();
((CallableEventExecutorAdapter<?>) task).executor() instanceof PausableEventExecutor &&
!((PausableEventExecutor) ((CallableEventExecutorAdapter<?>) task).executor()).isAcceptingNewTasks();
}
/**
@ -185,11 +180,11 @@ final class ScheduledFutureTask<V> extends PromiseTask<V> implements ScheduledFu
private boolean isMigrationPending() {
return !isCancelled() &&
task instanceof CallableEventExecutorAdapter &&
executor() != ((CallableEventExecutorAdapter) task).executor().unwrap();
executor() != ((CallableEventExecutorAdapter<?>) task).executor().unwrap();
}
private void scheduleWithNewExecutor() {
EventExecutor newExecutor = ((CallableEventExecutorAdapter) task).executor().unwrap();
EventExecutor newExecutor = ((CallableEventExecutorAdapter<?>) task).executor().unwrap();
if (newExecutor instanceof SingleThreadEventExecutor) {
if (!newExecutor.isShutdown()) {

View File

@ -820,15 +820,15 @@ public abstract class SingleThreadEventExecutor extends AbstractEventExecutor {
if (command instanceof RunnableEventExecutorAdapter) {
return new RunnableToCallableAdapter((RunnableEventExecutorAdapter) command);
} else {
return Executors.<Void>callable(command, null);
return Executors.callable(command, null);
}
}
protected void cleanupAndTerminate(boolean success) {
for (;;) {
int oldState = STATE_UPDATER.get(SingleThreadEventExecutor.this);
int oldState = STATE_UPDATER.get(this);
if (oldState >= ST_SHUTTING_DOWN || STATE_UPDATER.compareAndSet(
SingleThreadEventExecutor.this, oldState, ST_SHUTTING_DOWN)) {
this, oldState, ST_SHUTTING_DOWN)) {
break;
}
}
@ -851,7 +851,7 @@ public abstract class SingleThreadEventExecutor extends AbstractEventExecutor {
try {
cleanup();
} finally {
STATE_UPDATER.set(SingleThreadEventExecutor.this, ST_TERMINATED);
STATE_UPDATER.set(this, ST_TERMINATED);
threadLock.release();
if (!taskQueue.isEmpty()) {
logger.warn(