Checkstyle clean up about 200 trivial violation 11/42511/1
authorMichael Vorburger <vorburger@redhat.com>
Mon, 25 Jul 2016 23:12:40 +0000 (01:12 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Mon, 25 Jul 2016 23:12:40 +0000 (01:12 +0200)
I've intentionally started with the very simple formatting type changes
here.  This does not take care of everything yet, but it's a start.
Hopefully sending a few batches also makes it easier  (AssertionError e)
{to review.

Change-Id: Ibf328746c6880138a56eb36837bc8e789647b9bd
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
30 files changed:
common/util/src/main/java/org/opendaylight/yangtools/util/ClassLoaderUtils.java
common/util/src/main/java/org/opendaylight/yangtools/util/ConcurrentDurationStatisticsTracker.java
common/util/src/main/java/org/opendaylight/yangtools/util/DurationStatisticsTracker.java
common/util/src/main/java/org/opendaylight/yangtools/util/ExecutorServiceUtil.java
common/util/src/main/java/org/opendaylight/yangtools/util/HashCodeBuilder.java
common/util/src/main/java/org/opendaylight/yangtools/util/Identifiables.java
common/util/src/main/java/org/opendaylight/yangtools/util/ImmutableOffsetMap.java
common/util/src/main/java/org/opendaylight/yangtools/util/Immutables.java
common/util/src/main/java/org/opendaylight/yangtools/util/LazyCollections.java
common/util/src/main/java/org/opendaylight/yangtools/util/MapAdaptor.java
common/util/src/main/java/org/opendaylight/yangtools/util/ModifiableMapPhase.java
common/util/src/main/java/org/opendaylight/yangtools/util/MutableOffsetMap.java
common/util/src/main/java/org/opendaylight/yangtools/util/OffsetMapCache.java
common/util/src/main/java/org/opendaylight/yangtools/util/ReadWriteTrieMap.java
common/util/src/main/java/org/opendaylight/yangtools/util/UnmodifiableCollection.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/AsyncNotifyingListenableFutureTask.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/AsyncNotifyingListeningExecutorService.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/CachedThreadPoolExecutor.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/DeadlockDetectingListeningExecutorService.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/ExceptionMapper.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/FastThreadPoolExecutor.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/MappingCheckedFuture.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/NotificationManager.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/QueuedNotificationManager.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/ReflectiveExceptionMapper.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/SpecialExecutors.java
common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/TrackingLinkedBlockingQueue.java
common/util/src/test/java/org/opendaylight/yangtools/util/ConstantArrayCollectionTest.java
common/util/src/test/java/org/opendaylight/yangtools/util/OffsetMapTest.java
common/util/src/test/java/org/opendaylight/yangtools/util/concurrent/ThreadPoolExecutorTest.java

index 1ddd53df232b9709b7d20149a5f1c30202c9e6da..1cabaf4e3f4168e9ecb54f489c4d2f037ba35a2d 100644 (file)
@@ -33,7 +33,7 @@ public final class ClassLoaderUtils {
     /**
      * Runs {@link Supplier} with provided {@link ClassLoader}.
      *
-     * Invokes supplies function and makes sure that original {@link ClassLoader}
+     * <p>Invokes supplies function and makes sure that original {@link ClassLoader}
      * is context {@link ClassLoader} after execution.
      *
      * @param cls {@link ClassLoader} to be used.
@@ -85,14 +85,9 @@ public final class ClassLoaderUtils {
     }
 
     /**
-     *
      * Loads class using this supplied classloader.
      *
-     *
-     * @param cls
      * @param name String name of class.
-     * @return
-     * @throws ClassNotFoundException
      */
     public static Class<?> loadClass(final ClassLoader cls, final String name) throws ClassNotFoundException {
         if ("byte[]".equals(name)) {
@@ -148,10 +143,12 @@ public final class ClassLoaderUtils {
     }
 
     public static <S,G,P> Class<P> findFirstGenericArgument(final Class<S> scannedClass, final Class<G> genericType) {
-        return withClassLoader(scannedClass.getClassLoader(), ClassLoaderUtils.findFirstGenericArgumentTask(scannedClass, genericType));
+        return withClassLoader(scannedClass.getClassLoader(),
+                ClassLoaderUtils.findFirstGenericArgumentTask(scannedClass, genericType));
     }
 
-    private static <S,G,P> Supplier<Class<P>> findFirstGenericArgumentTask(final Class<S> scannedClass, final Class<G> genericType) {
+    private static <S, G, P> Supplier<Class<P>> findFirstGenericArgumentTask(final Class<S> scannedClass,
+            final Class<G> genericType) {
         return new Supplier<Class<P>>() {
             @Override
             @SuppressWarnings("unchecked")
index a06abbe25785c57408cecbcadfef672a75f58eec..085805af73b6598c254e50e453d91d16802fd16c 100644 (file)
@@ -16,10 +16,15 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
  */
 // TODO: once DurationStatsTracker is gone make this class final
 class ConcurrentDurationStatisticsTracker extends DurationStatisticsTracker {
-    private static final AtomicReferenceFieldUpdater<ConcurrentDurationStatisticsTracker, DurationWithTime> LONGEST_UPDATER =
-            AtomicReferenceFieldUpdater.newUpdater(ConcurrentDurationStatisticsTracker.class, DurationWithTime.class, "longest");
-    private static final AtomicReferenceFieldUpdater<ConcurrentDurationStatisticsTracker, DurationWithTime> SHORTEST_UPDATER =
-            AtomicReferenceFieldUpdater.newUpdater(ConcurrentDurationStatisticsTracker.class, DurationWithTime.class, "shortest");
+
+    private static final AtomicReferenceFieldUpdater<ConcurrentDurationStatisticsTracker, DurationWithTime>
+        LONGEST_UPDATER = AtomicReferenceFieldUpdater.newUpdater(ConcurrentDurationStatisticsTracker.class,
+                DurationWithTime.class, "longest");
+
+    private static final AtomicReferenceFieldUpdater<ConcurrentDurationStatisticsTracker, DurationWithTime>
+        SHORTEST_UPDATER = AtomicReferenceFieldUpdater.newUpdater(ConcurrentDurationStatisticsTracker.class,
+                DurationWithTime.class, "shortest");
+
     private static final AtomicLongFieldUpdater<ConcurrentDurationStatisticsTracker> COUNT_UPDATER =
             AtomicLongFieldUpdater.newUpdater(ConcurrentDurationStatisticsTracker.class, "count");
     private static final AtomicLongFieldUpdater<ConcurrentDurationStatisticsTracker> SUM_UPDATER =
index 810111d86bfa20d71242271bdb6097c07d0e83c0..a551642e39b6f166405c0a7a4d86242c2eef5b10 100644 (file)
@@ -205,23 +205,23 @@ public abstract class DurationStatisticsTracker {
 
     private static String abbreviate(final TimeUnit unit) {
         switch (unit) {
-        case NANOSECONDS:
-            return "ns";
-        case MICROSECONDS:
-            return "\u03bcs"; // μs
-        case MILLISECONDS:
-            return "ms";
-        case SECONDS:
-            return "s";
-        case MINUTES:
-            return "m";
-        case HOURS:
-            return "h";
-        case DAYS:
-            return "d";
-        default:
-            LOG.warn("Unhandled time unit {}", unit);
-            return "";
+            case NANOSECONDS:
+                return "ns";
+            case MICROSECONDS:
+                return "\u03bcs"; // μs
+            case MILLISECONDS:
+                return "ms";
+            case SECONDS:
+                return "s";
+            case MINUTES:
+                return "m";
+            case HOURS:
+                return "h";
+            case DAYS:
+                return "d";
+            default:
+                LOG.warn("Unhandled time unit {}", unit);
+                return "";
         }
     }
 }
index 429bb0bd0c0e66ce33b49f6f619bdbb1e004c4ee..cc5c38cbb1127e0132c92d5249ee2519c274d550 100644 (file)
@@ -91,7 +91,7 @@ public final class ExecutorServiceUtil {
             if (!executor.awaitTermination(timeout, unit)) {
                 executor.shutdownNow();
             }
-        } catch( InterruptedException e ) {
+        } catch (InterruptedException e) {
             executor.shutdownNow();
         }
     }
index f629ee53a9bdbf0679f4a3b6165c86b2f07914b8..541ae5540c33d3fd3f108e030636c013a1d9e20b 100644 (file)
@@ -17,14 +17,13 @@ import org.opendaylight.yangtools.concepts.Builder;
  */
 public final class HashCodeBuilder<T> implements Builder<Integer> {
     /**
-     *
      * The value 31 was chosen because it is an odd prime. If it were even and the multiplication
      * overflowed, information would be lost, as multiplication by 2 is equivalent to shifting. The
      * advantage of using a prime is less clear, but it is traditional. A nice property of 31 is
      * that the multiplication can be replaced by a shift and a subtraction for better performance:
      * 31 * i == (i << 5) - i. Modern VMs do this sort of optimization automatically.
      *
-     * (from Joshua Bloch's Effective Java, Chapter 3, Item 9: Always override hashcode when you
+     * <p>(from Joshua Bloch's Effective Java, Chapter 3, Item 9: Always override hashcode when you
      * override equals, page 48)
      */
     private static final int PRIME = 31;
index 313cffb0d4c6e956cb942936a4e5e999504f18bd..dbeee9bd2ea0b2338f5b3403ac7bba3a663c0837 100644 (file)
@@ -13,7 +13,9 @@ import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.concepts.Identifiable;
 
 public final class Identifiables {
-    private static final Function<Identifiable<Object>, Object> EXTRACT_IDENTIFIER = new Function<Identifiable<Object>, Object>() {
+
+    private static final Function<Identifiable<Object>, Object> EXTRACT_IDENTIFIER =
+            new Function<Identifiable<Object>, Object>() {
         @Override
         public Object apply(@Nonnull final Identifiable<Object> input) {
             Preconditions.checkNotNull(input);
index 7f923d6bb35cbeb9899c8bd382259b87d24d9052..909ab5583305110f8c92dfb070acb5c7d6220e1a 100644 (file)
@@ -102,14 +102,18 @@ public abstract class ImmutableOffsetMap<K, V> implements UnmodifiableMapPhase<K
     abstract void setFields(List<K> keys, V[] values) throws IOException;
 
     /**
-     * Create an {@link ImmutableOffsetMap} as a copy of an existing map. This is actually not completely true,
-     * as this method returns an {@link ImmutableMap} for empty and singleton inputs, as those are more memory-efficient.
-     * This method also recognizes {@link ImmutableOffsetMap} on input, and returns it back without doing anything else.
-     * It also recognizes {@link MutableOffsetMap} (as returned by {@link #toModifiableMap()}) and makes an efficient
-     * copy of its contents. All other maps are converted to an {@link ImmutableOffsetMap} with the same iteration
-     * order as input.
+     * Create an {@link ImmutableOffsetMap} as a copy of an existing map. This
+     * is actually not completely true, as this method returns an
+     * {@link ImmutableMap} for empty and singleton inputs, as those are more
+     * memory-efficient. This method also recognizes {@link ImmutableOffsetMap}
+     * on input, and returns it back without doing anything else. It also
+     * recognizes {@link MutableOffsetMap} (as returned by
+     * {@link #toModifiableMap()}) and makes an efficient copy of its contents.
+     * All other maps are converted to an {@link ImmutableOffsetMap} with the
+     * same iteration order as input.
      *
-     * @param m Input map, may not be null.
+     * @param m
+     *            Input map, may not be null.
      * @return An isolated, immutable copy of the input map
      */
     @Nonnull public static <K, V> Map<K, V> orderedCopyOf(@Nonnull final Map<K, V> m) {
@@ -145,14 +149,18 @@ public abstract class ImmutableOffsetMap<K, V> implements UnmodifiableMapPhase<K
     }
 
     /**
-     * Create an {@link ImmutableOffsetMap} as a copy of an existing map. This is actually not completely true,
-     * as this method returns an {@link ImmutableMap} for empty and singleton inputs, as those are more memory-efficient.
-     * This method also recognizes {@link ImmutableOffsetMap} on input, and returns it back without doing anything else.
-     * It also recognizes {@link MutableOffsetMap} (as returned by {@link #toModifiableMap()}) and makes an efficient
-     * copy of its contents. All other maps are converted to an {@link ImmutableOffsetMap}. Iterator order is not
-     * guaranteed to be retained.
+     * Create an {@link ImmutableOffsetMap} as a copy of an existing map. This
+     * is actually not completely true, as this method returns an
+     * {@link ImmutableMap} for empty and singleton inputs, as those are more
+     * memory-efficient. This method also recognizes {@link ImmutableOffsetMap}
+     * on input, and returns it back without doing anything else. It also
+     * recognizes {@link MutableOffsetMap} (as returned by
+     * {@link #toModifiableMap()}) and makes an efficient copy of its contents.
+     * All other maps are converted to an {@link ImmutableOffsetMap}. Iterator
+     * order is not guaranteed to be retained.
      *
-     * @param m Input map, may not be null.
+     * @param m
+     *            Input map, may not be null.
      * @return An isolated, immutable copy of the input map
      */
     @Nonnull public static <K, V> Map<K, V> unorderedCopyOf(@Nonnull final Map<K, V> m) {
@@ -385,7 +393,8 @@ public abstract class ImmutableOffsetMap<K, V> implements UnmodifiableMapPhase<K
         return f;
     }
 
-    private static void setField(final ImmutableOffsetMap<?, ?> map, final Field field, final Object value) throws IOException {
+    private static void setField(final ImmutableOffsetMap<?, ?> map, final Field field, final Object value)
+            throws IOException {
         try {
             field.set(map, value);
         } catch (IllegalArgumentException | IllegalAccessException e) {
index 73e254abe7d122cd5d6813dab65b7c3e81f39ac9..da5521f7425eb9ff9ee4f1f26f0ba967367195c3 100644 (file)
@@ -28,7 +28,7 @@ public final class Immutables {
     /**
      * Determines if object is known to be immutable
      *
-     * Note: This method may return false to immutable objects which
+     * <p>Note: This method may return false to immutable objects which
      * immutability is not known, was defined not using concepts term.
      *
      * @param o
index e5c21c41614ce8933d860c94d5a9ede90f27897a..1aa2c24960070238055344eded498299e0f5cabe 100644 (file)
@@ -33,14 +33,14 @@ public final class LazyCollections {
         final List<T> ret;
 
         switch (list.size()) {
-        case 0:
-            return Collections.singletonList(obj);
-        case 1:
-            ret = new ArrayList<>(2);
-            ret.addAll(list);
-            break;
-        default:
-            ret = list;
+            case 0:
+                return Collections.singletonList(obj);
+            case 1:
+                ret = new ArrayList<>(2);
+                ret.addAll(list);
+                break;
+            default:
+                ret = list;
         }
 
         ret.add(obj);
index 37a780c080c5ebb0101bbc68342e57e83a8b2966..df404a079ee4c74d5f75398a3f27b1e4f83afc97 100644 (file)
@@ -80,10 +80,12 @@ public final class MapAdaptor {
         return DEFAULT_INSTANCE;
     }
 
-    public static MapAdaptor getInstance(final boolean useSingleton, final int copyMaxItems, final int persistMinItems) {
+    public static MapAdaptor getInstance(final boolean useSingleton, final int copyMaxItems,
+            final int persistMinItems) {
         Preconditions.checkArgument(copyMaxItems >= 0, "copyMaxItems has to be a non-negative integer");
         Preconditions.checkArgument(persistMinItems >= 0, "persistMinItems has to be a positive integer");
-        Preconditions.checkArgument(persistMinItems <= copyMaxItems, "persistMinItems must be less than or equal to copyMaxItems");
+        Preconditions.checkArgument(persistMinItems <= copyMaxItems,
+                "persistMinItems must be less than or equal to copyMaxItems");
         return new MapAdaptor(useSingleton, copyMaxItems, persistMinItems);
     }
 
@@ -111,9 +113,6 @@ public final class MapAdaptor {
 
     /**
      * Input is treated is supposed to be left unmodified, result must be mutable.
-     *
-     * @param input
-     * @return
      */
     @SuppressWarnings("static-method")
     public <K, V> Map<K, V> takeSnapshot(final Map<K, V> input) {
@@ -134,18 +133,18 @@ public final class MapAdaptor {
         if (size <= 6) {
             final int target;
             switch (size) {
-            case 0:
-            case 1:
-                target = 1;
-                break;
-            case 2:
-                target = 2;
-                break;
-            case 3:
-                target = 4;
-                break;
-            default:
-                target = 8;
+                case 0:
+                case 1:
+                    target = 1;
+                    break;
+                case 2:
+                    target = 2;
+                    break;
+                case 3:
+                    target = 4;
+                    break;
+                default:
+                    target = 8;
             }
 
             ret = new HashMap<>(target);
index ddafd8d7625c47e5d513731ebbda3e7443719076..dbf3a72010ec61f8e7a0b9d7385e13cb918fdfcd 100644 (file)
@@ -14,13 +14,18 @@ import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.concepts.Mutable;
 
 /**
- * A {@link Map} which can be modified and supports efficient conversion to an unmodifiable map. This interface is the
- * logical counterpart to {@link UnmodifiableMapPhase}, but it does not require implementations of {@link #toUnmodifiableMap()}
- * to return an implementation of that interface. The reason for that empty and singleton mappings are efficiently
- * represented as {@link ImmutableMap}, which does not implement {@link UnmodifiableMapPhase}.
+ * A {@link Map} which can be modified and supports efficient conversion to an
+ * unmodifiable map. This interface is the logical counterpart to
+ * {@link UnmodifiableMapPhase}, but it does not require implementations of
+ * {@link #toUnmodifiableMap()} to return an implementation of that interface.
+ * The reason for that empty and singleton mappings are efficiently represented
+ * as {@link ImmutableMap}, which does not implement
+ * {@link UnmodifiableMapPhase}.
  *
- * @param <K> the type of keys maintained by this map
- * @param <V> the type of mapped values
+ * @param <K>
+ *            the type of keys maintained by this map
+ * @param <V>
+ *            the type of mapped values
  */
 @Beta
 public interface ModifiableMapPhase<K, V> extends Map<K, V>, Mutable {
index dee904fbe7ff0ef52ac99d763d4c59cf450fbe61..c9903d4ab0ec69f25813667b9884d45add53ba8f 100644 (file)
@@ -35,7 +35,7 @@ import java.util.Set;
  * </code>
  * results in source and result sharing the backing objects.
  *
- * This map does not support null keys nor values.
+ * <p>This map does not support null keys nor values.
  *
  * @param <K> the type of keys maintained by this map
  * @param <V> the type of mapped values
@@ -176,8 +176,11 @@ public abstract class MutableOffsetMap<K, V> extends AbstractMap<K, V> implement
     }
 
     abstract Object removedObject();
+
     abstract UnmodifiableMapPhase<K, V> modifiedMap(List<K> keys, V[] objects);
+
     abstract UnmodifiableMapPhase<K, V> unmodifiedMap(Map<K, Integer> offsets, V[] objects);
+
     abstract SharedSingletonMap<K, V> singletonMap();
 
     @Override
@@ -390,7 +393,7 @@ public abstract class MutableOffsetMap<K, V> extends AbstractMap<K, V> implement
         try {
             ret = (MutableOffsetMap<K, V>) super.clone();
         } catch (CloneNotSupportedException e) {
-           throw new IllegalStateException("Clone is expected to work", e);
+            throw new IllegalStateException("Clone is expected to work", e);
         }
 
         ret.newKeys = (HashMap<K, V>) newKeys.clone();
@@ -573,7 +576,8 @@ public abstract class MutableOffsetMap<K, V> extends AbstractMap<K, V> implement
         private final Iterator<Entry<K, Integer>> oldIterator = offsets.entrySet().iterator();
         private final Iterator<K> newIterator = newKeys.keySet().iterator();
         private int expectedModCount = modCount;
-        private K currentKey, nextKey;
+        private K currentKey;
+        private K nextKey;
 
         AbstractSetIterator() {
             updateNextKey();
index b18c218f2185e1920928e0a35a905b79da9e62ea..c3f67e9243d2131edfa2e41596d2843b2f945792 100644 (file)
@@ -35,7 +35,7 @@ final class OffsetMapCache {
                 public Map<?, Integer> load(final List<?> key) {
                     return createMap(key);
                 }
-    });
+            });
     /*
      * Cache for offsets where order does not mapper. The key is a Set of elements. We use manual two-stage loading
      * because of the nature of the objects we store as values, which is ImmutableMaps. An ImmutableMap, when queried
index f860a7b4641e931e830c9f05cadf0f1e7aebc7ed..6250dd3640d2f49e9e847f881903c1f95d56c4ae 100644 (file)
@@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory;
  * their size, and determining the size of a TrieMap is expensive, we make sure
  * to update it as we go.
  *
- * FIXME: this map does not support modification view the keySet()/values()/entrySet()
+ * <p>FIXME: this map does not support modification view the keySet()/values()/entrySet()
  *        methods.
  *
  * @param <K> Key type
index ca6415f0e31b928c9f5d6ef11b5472262dc87ef0..29ccab5e40bc8c47def2672676457a7a4df3f868 100644 (file)
@@ -24,10 +24,9 @@ import javax.annotation.Nonnull;
  * {@link Collections#unmodifiableCollection(Collection)}, this class checks its
  * argument to ensure multiple encapsulation does not occur.
  *
- * this class checks
+ * <p>This class checks
  * the argument so it prevents multiple encapsulation. Subclasses of
  * {@link ImmutableCollection} are also recognized and not encapsulated.
- * An attempt is also made to identi
  *
  * @param <E> the type of elements in this collection
  */
index bd0919aecfc56e6d87f94046339df589a7b0c52b..0e36b74da3dc9c8d50721388ee438197cfa84fb0 100644 (file)
@@ -29,13 +29,13 @@ import org.slf4j.LoggerFactory;
  * to avoid blocking the thread that completed this task, as a common use case is to pass an
  * executor that runs tasks in the same thread as the caller (ie MoreExecutors#sameThreadExecutor)
  * to {@link #addListener}.
- * <p>
- * Note: the Executor specified on construction does not replace the Executor specified in
+ *
+ * <p>Note: the Executor specified on construction does not replace the Executor specified in
  * {@link #addListener}. The latter Executor is still used however, if it is detected that the
  * listener Runnable would execute in the thread that completed this task, the listener
  * is executed on Executor specified on construction.
  *
- * Also note that the use of this task may attach some (small) amount of state to the threads
+ * <p>Also note that the use of this task may attach some (small) amount of state to the threads
  * interacting with it. That state will not be detached automatically, but you can use
  *  {@link #cleanStateForCurrentThread()} to clean it up.
  *
@@ -45,13 +45,17 @@ import org.slf4j.LoggerFactory;
  * @param <V> the Future result value type
  */
 public class AsyncNotifyingListenableFutureTask<V> extends FutureTask<V> implements ListenableFuture<V> {
-    private static final class DelegatingAsyncNotifyingListenableFutureTask<V> extends AsyncNotifyingListenableFutureTask<V> {
+
+    private static final class DelegatingAsyncNotifyingListenableFutureTask<V>
+            extends AsyncNotifyingListenableFutureTask<V> {
+
         /**
          * The executor used to run listener callbacks.
          */
         private final Executor listenerExecutor;
 
-        private DelegatingAsyncNotifyingListenableFutureTask(final Callable<V> callable, @Nullable final Executor listenerExecutor) {
+        private DelegatingAsyncNotifyingListenableFutureTask(final Callable<V> callable,
+                @Nullable final Executor listenerExecutor) {
             super(callable);
             this.listenerExecutor = Preconditions.checkNotNull(listenerExecutor);
         }
index d57ded358f4ab7b1013c84ab4edd03119ceb327c..024594d0f2c1b832ff06973a4f651725493c364a 100644 (file)
@@ -21,23 +21,31 @@ import java.util.concurrent.TimeUnit;
 import javax.annotation.Nullable;
 
 /**
- * An {@link com.google.common.util.concurrent.ListeningExecutorService} implementation that also allows for an {@link Executor} to be
- * specified on construction that is used to execute {@link ListenableFuture} callback Runnables,
- * registered via {@link com.google.common.util.concurrent.Futures#addCallback} or {@link ListenableFuture#addListener} directly,
- * asynchronously when a task that is run on this executor completes. This is useful when you want
- * to guarantee listener callback executions are off-loaded onto another thread to avoid blocking
- * the thread that completed the task, as a common use case is to pass an executor that runs tasks
- * in the same thread as the caller (ie <code>MoreExecutors#sameThreadExecutor</code>}) to
+ * An {@link com.google.common.util.concurrent.ListeningExecutorService}
+ * implementation that also allows for an {@link Executor} to be specified on
+ * construction that is used to execute {@link ListenableFuture} callback
+ * Runnables, registered via
+ * {@link com.google.common.util.concurrent.Futures#addCallback} or
+ * {@link ListenableFuture#addListener} directly, asynchronously when a task
+ * that is run on this executor completes. This is useful when you want to
+ * guarantee listener callback executions are off-loaded onto another thread to
+ * avoid blocking the thread that completed the task, as a common use case is to
+ * pass an executor that runs tasks in the same thread as the caller (ie
+ * <code>MoreExecutors#sameThreadExecutor</code>}) to
  * {@link ListenableFuture#addListener}.
+ *
  * <p>
- * Most commonly, this class would be used in lieu of <code>MoreExecutors#listeningDecorator</code>
- * when the underlying delegate Executor is single-threaded, in which case, you may not want
- * ListenableFuture callbacks to block the single thread.
+ * Most commonly, this class would be used in lieu of
+ * <code>MoreExecutors#listeningDecorator</code> when the underlying delegate
+ * Executor is single-threaded, in which case, you may not want ListenableFuture
+ * callbacks to block the single thread.
+ *
  * <p>
- * Note: the Executor specified on construction does not replace the Executor specified in
- * {@link ListenableFuture#addListener}. The latter Executor is still used however, if it is
- * detected that the listener Runnable would execute in the thread that completed the task, the
- * listener is executed on Executor specified on construction.
+ * Note: the Executor specified on construction does not replace the Executor
+ * specified in {@link ListenableFuture#addListener}. The latter Executor is
+ * still used however, if it is detected that the listener Runnable would
+ * execute in the thread that completed the task, the listener is executed on
+ * Executor specified on construction.
  *
  * @author Thomas Pantelis
  * @see AsyncNotifyingListenableFutureTask
index 7f2e77f73141c5819bea990834a86008c7b5701e..2ef1cd83969bbf401162fc239d9a95ba5a724f4a 100644 (file)
@@ -22,8 +22,8 @@ import java.util.concurrent.TimeUnit;
 /**
  * A ThreadPoolExecutor with a specified bounded queue capacity that favors reusing previously
  * constructed threads, when they are available, over creating new threads.
- * <p>
- * See {@link SpecialExecutors#newBoundedCachedThreadPool} for more details.
+ *
+ * <p>See {@link SpecialExecutors#newBoundedCachedThreadPool} for more details.
  *
  * @author Thomas Pantelis
  */
@@ -50,7 +50,7 @@ public class CachedThreadPoolExecutor extends ThreadPoolExecutor {
      * @param threadPrefix
      *            the name prefix for threads created by this executor.
      */
-    public CachedThreadPoolExecutor( final int maximumPoolSize, final int maximumQueueSize, final String threadPrefix ) {
+    public CachedThreadPoolExecutor(final int maximumPoolSize, final int maximumQueueSize, final String threadPrefix) {
         // We're using a custom SynchronousQueue that has a backing bounded LinkedBlockingQueue.
         // We don't specify any core threads (first parameter) so, when a task is submitted,
         // the base class will always try to offer to the queue. If there is an existing waiting
@@ -204,7 +204,7 @@ public class CachedThreadPoolExecutor extends ThreadPoolExecutor {
             this.delegateRejectedExecutionHandler = delegateRejectedExecutionHandler;
         }
 
-        RejectedExecutionHandler getDelegateRejectedExecutionHandler(){
+        RejectedExecutionHandler getDelegateRejectedExecutionHandler() {
             return delegateRejectedExecutionHandler;
         }
 
index 2cfdba290f46fb102c8687e6e2a6d9d0fb4fa8a1..8cdbc2c41373827e5f26baab4fe544f2e87d7f9d 100644 (file)
@@ -24,8 +24,8 @@ import javax.annotation.Nullable;
 /**
  * An implementation of ListeningExecutorService that attempts to detect deadlock scenarios that
  * could occur if clients invoke the returned Future's <code>get</code> methods synchronously.
- * <p>
- * Deadlock scenarios are most apt to occur with a backing single-threaded executor where setting of
+ *
+ * <p>Deadlock scenarios are most apt to occur with a backing single-threaded executor where setting of
  * the Future's result is executed on the single thread. Here's a scenario:
  * <ul>
  * <li>Client code is currently executing in an executor's single thread.</li>
@@ -35,13 +35,13 @@ import javax.annotation.Nullable;
  * The second submitted task will never execute since the single thread is currently executing
  * the client code which is blocked waiting for the submitted task to complete. Thus, deadlock has
  * occurred.
- * <p>
- * This class prevents this scenario via the use of a ThreadLocal variable. When a task is invoked,
+ *
+ * <p>This class prevents this scenario via the use of a ThreadLocal variable. When a task is invoked,
  * the ThreadLocal is set and, when a task completes, the ThreadLocal is cleared. Futures returned
  * from this class override the <code>get</code> methods to check if the ThreadLocal is set. If it is,
  * an ExecutionException is thrown with a custom cause.
  *
- * Note that the ThreadLocal is not removed automatically, so some state may be left hanging off of
+ * <p>Note that the ThreadLocal is not removed automatically, so some state may be left hanging off of
  * threads which have encountered this class. If you need to clean that state up, use
  * {@link #cleanStateForCurrentThread()}.
  *
index 88cf7537e6b275a9d02b45dca5132b079b06d647..1616cd24aaebc4c6b7512c7493195b629194ebcd 100644 (file)
@@ -14,20 +14,28 @@ import java.util.concurrent.CancellationException;
 import java.util.concurrent.ExecutionException;
 
 /**
- * Utility exception mapper which translates an Exception to a specified type of Exception.
+ * Utility exception mapper which translates an Exception to a specified type of
+ * Exception.
  *
- * This mapper is intended to be used with {@link com.google.common.util.concurrent.Futures#makeChecked(com.google.common.util.concurrent.ListenableFuture, Function)}
+ * <p>
+ * This mapper is intended to be used with
+ * {@link com.google.common.util.concurrent.Futures#makeChecked(com.google.common.util.concurrent.ListenableFuture, Function)}
  * <ul>
- * <li>if exception is the specified type or one of its subclasses, it returns original exception.
- * <li>if exception is {@link ExecutionException} and the cause is of the specified type, it returns the cause
- * <li>otherwise returns an instance of the specified exception type with original exception as the cause.
+ * <li>if exception is the specified type or one of its subclasses, it returns
+ * original exception.
+ * <li>if exception is {@link ExecutionException} and the cause is of the
+ * specified type, it returns the cause
+ * <li>otherwise returns an instance of the specified exception type with
+ * original exception as the cause.
  * </ul>
  *
  * @author Thomas Pantelis
  *
- * @param <X> the exception type
+ * @param <X>
+ *            the exception type
  */
 public abstract class ExceptionMapper<X extends Exception> implements Function<Exception, X> {
+
     private final Class<X> exceptionType;
     private final String opName;
 
index f46dcbcd5cc75f64b36151ebcab847b7bdeacc8d..24fb7b82745035f2ee3d427705a7bb83db43f742 100644 (file)
@@ -17,8 +17,8 @@ import java.util.concurrent.TimeUnit;
 /**
  * A ThreadPoolExecutor with a specified bounded queue capacity that favors creating new threads
  * over queuing, as the former is faster.
- * <p>
- * See {@link SpecialExecutors#newBoundedFastThreadPool} for more details.
+ *
+ * <p>See {@link SpecialExecutors#newBoundedFastThreadPool} for more details.
  *
  * @author Thomas Pantelis
  */
index 571411d24fd37878b74faed6a88582b5a0b6a7f6..7e89be8199ffde443888e328830c88f73b17b60f 100644 (file)
@@ -20,11 +20,11 @@ import java.util.concurrent.TimeoutException;
 /**
  * An implementation of CheckedFuture that provides similar behavior for the <code>get</code> methods
  * that the <code>checkedGet</code> methods provide.
- * <p>
- * For {@link CancellationException} and {@link InterruptedException}, the specified exception mapper
+ *
+ * <p>For {@link CancellationException} and {@link InterruptedException}, the specified exception mapper
  * is invoked to translate them to the checked exception type.
- * <p>
- * For {@link ExecutionException}, the mapper is invoked to translate the cause to the checked exception
+ *
+ * <p>For {@link ExecutionException}, the mapper is invoked to translate the cause to the checked exception
  * and a new ExecutionException is thrown with the translated cause.
  *
  * @author Thomas Pantelis
@@ -67,12 +67,12 @@ public final class MappingCheckedFuture<V, X extends Exception> extends Abstract
     public V get() throws InterruptedException, ExecutionException {
         try {
             return super.get();
-        } catch( final InterruptedException e ) {
+        } catch (final InterruptedException e) {
             Thread.currentThread().interrupt();
             throw wrapInExecutionException( "Operation was interrupted", e );
-        } catch( final CancellationException e ) {
+        } catch (final CancellationException e) {
             throw wrapInExecutionException( "Operation was cancelled", e );
-        } catch( final ExecutionException e ) {
+        } catch (final ExecutionException e) {
             throw wrapInExecutionException( e.getMessage(), e );
         }
     }
@@ -82,12 +82,12 @@ public final class MappingCheckedFuture<V, X extends Exception> extends Abstract
             throws InterruptedException, ExecutionException, TimeoutException {
         try {
             return super.get( timeout, unit );
-        } catch( final InterruptedException e ) {
+        } catch (final InterruptedException e) {
             Thread.currentThread().interrupt();
             throw wrapInExecutionException( "Operation was interrupted", e );
-        } catch( final CancellationException e ) {
+        } catch (final CancellationException e) {
             throw wrapInExecutionException( "Operation was cancelled", e );
-        } catch( final ExecutionException e ) {
+        } catch (final ExecutionException e) {
             throw wrapInExecutionException( e.getMessage(), e );
         }
     }
index aee3c9967639bfff299acea8074a2d75c30a9fc6..a184ec679024b95a49a08c088013d5b53f927892 100644 (file)
@@ -22,8 +22,8 @@ public interface NotificationManager<L, N> {
 
     /**
      * Submits a notification to be queued and dispatched to the given listener.
-     * <p>
-     * <b>Note:</b> This method may block if the listener queue is currently full.
+     *
+     * <p><b>Note:</b> This method may block if the listener queue is currently full.
      *
      * @param listener the listener to notify
      * @param notification the notification to dispatch
@@ -33,8 +33,8 @@ public interface NotificationManager<L, N> {
 
     /**
      * Submits notifications to be queued and dispatched to the given listener.
-     * <p>
-     * <b>Note:</b> This method may block if the listener queue is currently full.
+     *
+     * <p><b>Note:</b> This method may block if the listener queue is currently full.
      *
      * @param listener the listener to notify
      * @param notifications the notifications to dispatch
@@ -42,4 +42,4 @@ public interface NotificationManager<L, N> {
      */
     void submitNotifications( final L listener, Iterable<N> notifications);
 
-}
\ No newline at end of file
+}
index 09d867b15c58551672cf0f7ff2534aa0215624e8..90783f2cdc32d06be07e47c907a7504bd543db67 100644 (file)
@@ -29,8 +29,8 @@ import org.slf4j.LoggerFactory;
  * This class manages queuing and dispatching notifications for multiple listeners concurrently.
  * Notifications are queued on a per-listener basis and dispatched serially to each listener via an
  * {@link Executor}.
- * <p>
- * This class optimizes its memory footprint by only allocating and maintaining a queue and executor
+ *
+ * <p>This class optimizes its memory footprint by only allocating and maintaining a queue and executor
  * task for a listener when there are pending notifications. On the first notification(s), a queue
  * is created and a task is submitted to the executor to dispatch the queue to the associated
  * listener. Any subsequent notifications that occur before all previous notifications have been
@@ -172,7 +172,7 @@ public class QueuedNotificationManager<L,N> implements NotificationManager<L,N>
                     break;
                 }
             }
-        } catch( InterruptedException e ) {
+        } catch (InterruptedException e) {
 
             // We were interrupted trying to offer to the listener's queue. Somebody's probably
             // telling us to quit.
@@ -204,14 +204,14 @@ public class QueuedNotificationManager<L,N> implements NotificationManager<L,N>
     /**
      * Returns the maximum listener queue capacity.
      */
-    public int getMaxQueueCapacity(){
+    public int getMaxQueueCapacity() {
         return maxQueueCapacity;
     }
 
     /**
      * Returns the {@link Executor} to used for notification tasks.
      */
-    public Executor getExecutor(){
+    public Executor getExecutor() {
         return executor;
     }
 
@@ -226,7 +226,7 @@ public class QueuedNotificationManager<L,N> implements NotificationManager<L,N>
 
         private final L listener;
 
-        public ListenerKey( L listener ) {
+        ListenerKey( L listener ) {
             this.listener = listener;
         }
 
@@ -315,19 +315,18 @@ public class QueuedNotificationManager<L,N> implements NotificationManager<L,N>
                         }
 
                         LOG.warn(
-                            "{}: Timed out trying to offer a notification to the queue for listener {} " +
-                            "on attempt {} of {}. " +
-                            "The queue has reached its capacity of {}",
-                            name, listenerKey.toString(), notificationOfferAttempts, MAX_NOTIFICATION_OFFER_ATTEMPTS,
-                            maxQueueCapacity );
+                                "{}: Timed out trying to offer a notification to the queue for listener {} "
+                                        + "on attempt {} of {}. " + "The queue has reached its capacity of {}",
+                                name, listenerKey.toString(), notificationOfferAttempts,
+                                MAX_NOTIFICATION_OFFER_ATTEMPTS, maxQueueCapacity);
                     }
                     if (!notificationOfferAttemptSuccess) {
                         LOG.warn(
-                            "{}: Failed to offer a notification to the queue for listener {}. " +
-                            "Exceeded max allowable attempts of {} in {} minutes; the listener " +
-                            "is likely in an unrecoverable state (deadlock or endless loop).",
-                            name, listenerKey.toString(), MAX_NOTIFICATION_OFFER_ATTEMPTS,
-                            MAX_NOTIFICATION_OFFER_ATTEMPTS );
+                                "{}: Failed to offer a notification to the queue for listener {}. "
+                                        + "Exceeded max allowable attempts of {} in {} minutes; the listener "
+                                        + "is likely in an unrecoverable state (deadlock or endless loop).",
+                                name, listenerKey.toString(), MAX_NOTIFICATION_OFFER_ATTEMPTS,
+                                MAX_NOTIFICATION_OFFER_ATTEMPTS);
                     }
                 }
 
@@ -389,7 +388,7 @@ public class QueuedNotificationManager<L,N> implements NotificationManager<L,N>
 
                     notifyListener( notification );
                 }
-            } catch( InterruptedException e ) {
+            } catch (InterruptedException e) {
 
                 // The executor is probably shutting down so log as debug.
                 LOG.debug( "{}: Interrupted trying to remove from {} listener's queue",
@@ -418,7 +417,7 @@ public class QueuedNotificationManager<L,N> implements NotificationManager<L,N>
 
                 listenerInvoker.invokeListener( listenerKey.getListener(), notification );
 
-            } catchRuntimeException e ) {
+            } catch (RuntimeException e ) {
 
                 // We'll let a RuntimeException from the listener slide and keep sending any
                 // remaining notifications.
@@ -426,7 +425,7 @@ public class QueuedNotificationManager<L,N> implements NotificationManager<L,N>
                 LOG.error( String.format( "%1$s: Error notifying listener %2$s", name,
                            listenerKey.toString() ), e );
 
-            } catch( Error e ) {
+            } catch (Error e) {
 
                 // A JVM Error is severe - best practice is to throw them up the chain. Set done to
                 // true so no new notifications can be added to this task as we're about to bail.
index d49f80662d674f366a2645730bdd9638f1860e97..b00ed4f30472227496464bae1ac1aea60da44e9d 100644 (file)
@@ -45,7 +45,8 @@ public final class ReflectiveExceptionMapper<X extends Exception> extends Except
      * @throws IllegalArgumentException when the supplied exception class does not pass sanity checks
      * @throws SecurityException when the required constructor is not accessible
      */
-    public static <X extends Exception> ReflectiveExceptionMapper<X> create(final String opName, final Class<X> exceptionType) throws SecurityException {
+    public static <X extends Exception> ReflectiveExceptionMapper<X> create(final String opName,
+            final Class<X> exceptionType) throws SecurityException {
         final Constructor<X> c;
         try {
             c = exceptionType.getConstructor(String.class, Throwable.class);
@@ -55,7 +56,8 @@ public final class ReflectiveExceptionMapper<X extends Exception> extends Except
 
         try {
             c.newInstance(opName, new Throwable());
-        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
+                | InvocationTargetException e) {
             throw new IllegalArgumentException("Constructor " + c.getName() + " failed to pass instantiation test", e);
         }
 
index 110ac1eedab6e39bcce03955ef2ee471b143cc8e..929ecc01069b83694048f4a5a3a65ba78108cb1e 100644 (file)
@@ -26,17 +26,17 @@ public final class SpecialExecutors {
      * threads over queuing, as the former is faster, so threads will only be reused when the thread
      * limit is exceeded and tasks are queued. If the maximum queue capacity is reached, subsequent
      * tasks will be rejected.
-     * <p>
-     * For example, if the maximum number of threads is 100 and 100 short-lived tasks are submitted
+     *
+     * <p>For example, if the maximum number of threads is 100 and 100 short-lived tasks are submitted
      * within say 10 seconds, then 100 threads will be created and used - previously constructed
      * idle threads will not be reused. This provides the fastest execution of the 100 tasks at the
      * expense of memory and thread resource overhead. Therefore it is advisable to specify a
      * relatively small thread limit (probably no more than 50).
-     * <p>
-     * Threads that have not been used for 15 seconds are terminated and removed from the pool.
+     *
+     * <p>Threads that have not been used for 15 seconds are terminated and removed from the pool.
      * Thus, a pool that remains idle for long enough will not consume any resources.
-     * <p>
-     * If you need an executor with less memory and thread resource overhead where slower execution
+     *
+     * <p>If you need an executor with less memory and thread resource overhead where slower execution
      * time is acceptable, consider using {@link #newBoundedCachedThreadPool }.
      *
      * @param maximumPoolSize
@@ -85,14 +85,14 @@ public final class SpecialExecutors {
      * thread to execute. If the specified maximum thread limit is reached, subsequent tasks will be
      * queued and will execute as threads become available. If the maximum queue capacity is
      * reached, subsequent tasks will be rejected.
-     * <p>
-     * Threads that have not been used for sixty seconds are terminated and removed from the pool.
+     *
+     * <p>Threads that have not been used for sixty seconds are terminated and removed from the pool.
      * Thus, a pool that remains idle for long enough will not consume any resources.
-     * <p>
-     * By reusing threads when possible, this executor optimizes for reduced memory and thread
+     *
+     * <p>By reusing threads when possible, this executor optimizes for reduced memory and thread
      * resource overhead at the expense of execution time.
-     * <p>
-     * If you need an executor with faster execution time where increased memory and thread resource
+     *
+     * <p>If you need an executor with faster execution time where increased memory and thread resource
      * overhead is acceptable, consider using {@link #newBoundedFastThreadPool }.
      *
      * @param maximumPoolSize
index 0a0f54da5097743666665f91bf33fc0a43cc6ca4..546dec3d65336077a1e18771374293c16ab554c0 100644 (file)
@@ -22,13 +22,15 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
  * @param <E> the element t.ype
  */
 public class TrackingLinkedBlockingQueue<E> extends LinkedBlockingQueue<E> {
-    @SuppressWarnings("rawtypes")
-    private static final AtomicIntegerFieldUpdater<TrackingLinkedBlockingQueue> LARGEST_QUEUE_SIZE_UPDATER = AtomicIntegerFieldUpdater.newUpdater(TrackingLinkedBlockingQueue.class, "largestQueueSize");
     private static final long serialVersionUID = 1L;
 
+    @SuppressWarnings("rawtypes")
+    private static final AtomicIntegerFieldUpdater<TrackingLinkedBlockingQueue> LARGEST_QUEUE_SIZE_UPDATER
+        = AtomicIntegerFieldUpdater.newUpdater(TrackingLinkedBlockingQueue.class, "largestQueueSize");
+
     /**
      * Holds largestQueueSize, this long field should be only accessed
-     * using {@link #LARGEST_QUEUE_SIZE_UPDATER}
+     * using {@link #LARGEST_QUEUE_SIZE_UPDATER}.
      */
     private volatile int largestQueueSize = 0;
 
@@ -56,7 +58,7 @@ public class TrackingLinkedBlockingQueue<E> extends LinkedBlockingQueue<E> {
     /**
      * Returns the largest queue size.
      *
-     * FIXME: the this return will be changed to int in a future release.
+     * <p>FIXME: the this return will be changed to int in a future release.
      */
     @Beta
     public long getLargestQueueSize() {
@@ -64,7 +66,7 @@ public class TrackingLinkedBlockingQueue<E> extends LinkedBlockingQueue<E> {
     }
 
     @Override
-    public boolean offer( final E e, final long timeout, final TimeUnit unit ) throws InterruptedException {
+    public boolean offer(final E e, final long timeout, final TimeUnit unit) throws InterruptedException {
         if (super.offer( e, timeout, unit ) ) {
             updateLargestQueueSize();
             return true;
@@ -74,7 +76,7 @@ public class TrackingLinkedBlockingQueue<E> extends LinkedBlockingQueue<E> {
     }
 
     @Override
-    public boolean offer( final E e ) {
+    public boolean offer(final E e) {
         if (super.offer( e ) ) {
             updateLargestQueueSize();
             return true;
@@ -90,14 +92,14 @@ public class TrackingLinkedBlockingQueue<E> extends LinkedBlockingQueue<E> {
     }
 
     @Override
-    public boolean add( final E e ) {
+    public boolean add(final E e) {
         boolean result = super.add( e );
         updateLargestQueueSize();
         return result;
     }
 
     @Override
-    public boolean addAll( final Collection<? extends E> c ) {
+    public boolean addAll(final Collection<? extends E> c) {
         try {
             return super.addAll( c );
         } finally {
index 5cde0d0c7065fd15e12b05626f8dd47f6f58f198..11aac6ccf067b431f142835969d3b43ca23cb5d4 100644 (file)
@@ -67,36 +67,42 @@ public class ConstantArrayCollectionTest {
             c.add(null);
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             c.remove(null);
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             c.addAll(null);
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             c.removeAll(null);
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             c.retainAll(null);
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             c.clear();
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
     }
 }
index b5f0f50f6aeabb71fcf479c2717b84da46d523d5..fad0f29da733749117de8f73a76cc6f6bd30dff7 100644 (file)
@@ -51,7 +51,7 @@ public class OffsetMapTest {
         OffsetMapCache.invalidateCache();
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testWrongImmutableConstruction() {
         new ImmutableOffsetMap.Ordered<>(Collections.<String, Integer>emptyMap(), new String[1]);
     }
@@ -127,18 +127,21 @@ public class OffsetMapTest {
             map.values().add("v1");
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.values().remove("v1");
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.values().clear();
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
@@ -147,24 +150,28 @@ public class OffsetMapTest {
             it.remove();
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.keySet().add("k1");
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.keySet().clear();
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.keySet().remove("k1");
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
@@ -173,24 +180,28 @@ public class OffsetMapTest {
             it.remove();
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.entrySet().clear();
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.entrySet().add(new SimpleEntry<>("k1", "v1"));
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.entrySet().remove(new SimpleEntry<>("k1", "v1"));
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
@@ -199,30 +210,35 @@ public class OffsetMapTest {
             it.remove();
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.clear();
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.put("k1", "fail");
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.putAll(ImmutableMap.of("k1", "fail"));
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
 
         try {
             map.remove("k1");
             fail();
         } catch (UnsupportedOperationException e) {
+            // OK
         }
     }
 
@@ -314,7 +330,8 @@ public class OffsetMapTest {
         mutable.remove("non-existent");
 
         // Resulting map should be equal, but not the same object
-        final ImmutableOffsetMap<String, String> result = (ImmutableOffsetMap<String, String>) mutable.toUnmodifiableMap();
+        final ImmutableOffsetMap<String, String> result = (ImmutableOffsetMap<String, String>) mutable
+                .toUnmodifiableMap();
         assertNotSame(source, result);
         assertEquals(source, result);
 
@@ -331,7 +348,8 @@ public class OffsetMapTest {
         mutable.remove("k1");
         mutable.put("k1", "v1");
 
-        final ImmutableOffsetMap<String, String> result = (ImmutableOffsetMap<String, String>) mutable.toUnmodifiableMap();
+        final ImmutableOffsetMap<String, String> result = (ImmutableOffsetMap<String, String>) mutable
+                .toUnmodifiableMap();
         assertTrue(source.equals(result));
         assertTrue(result.equals(source));
 
@@ -347,7 +365,8 @@ public class OffsetMapTest {
         mutable.remove("k1");
         mutable.put("k1", "v1");
 
-        final ImmutableOffsetMap<String, String> result = (ImmutableOffsetMap<String, String>) mutable.toUnmodifiableMap();
+        final ImmutableOffsetMap<String, String> result = (ImmutableOffsetMap<String, String>) mutable
+                .toUnmodifiableMap();
         assertEquals(source, result);
 
         // Only offsets should be shared
@@ -461,7 +480,8 @@ public class OffsetMapTest {
 
         mutable.put("k1", "replaced");
 
-        final ImmutableOffsetMap<String, String> result = (ImmutableOffsetMap<String, String>) mutable.toUnmodifiableMap();
+        final ImmutableOffsetMap<String, String> result = (ImmutableOffsetMap<String, String>) mutable
+                .toUnmodifiableMap();
         final Map<String, String> reference = ImmutableMap.of("k1", "replaced", "k2", "v2");
 
         assertEquals(reference, result);
@@ -497,7 +517,8 @@ public class OffsetMapTest {
         assertTrue(result.needClone());
 
         // Forced copy, no cloning needed, but maps are equal
-        final ImmutableOffsetMap<String, String> immutable = (ImmutableOffsetMap<String, String>) source.toUnmodifiableMap();
+        final ImmutableOffsetMap<String, String> immutable = (ImmutableOffsetMap<String, String>) source
+                .toUnmodifiableMap();
         assertFalse(source.needClone());
         assertTrue(source.equals(immutable));
         assertTrue(immutable.equals(source));
@@ -531,7 +552,8 @@ public class OffsetMapTest {
         assertTrue(result.needClone());
 
         // Creates a immutable view, which shares the array
-        final ImmutableOffsetMap<String, String> immutable = (ImmutableOffsetMap<String, String>) source.toUnmodifiableMap();
+        final ImmutableOffsetMap<String, String> immutable = (ImmutableOffsetMap<String, String>) source
+                .toUnmodifiableMap();
         assertTrue(source.needClone());
         assertSame(source.array(), immutable.objects());
     }
@@ -564,16 +586,19 @@ public class OffsetMapTest {
             it.hasNext();
             fail();
         } catch (ConcurrentModificationException e) {
+            // OK
         }
         try {
             it.next();
             fail();
         } catch (ConcurrentModificationException e) {
+            // OK
         }
         try {
             it.remove();
             fail();
         } catch (ConcurrentModificationException e) {
+            // OK
         }
     }
 
@@ -605,6 +630,7 @@ public class OffsetMapTest {
             it.remove();
             fail();
         } catch (IllegalStateException e) {
+            // OK
         }
 
         assertTrue(it.hasNext());
@@ -618,6 +644,7 @@ public class OffsetMapTest {
             it.next();
             fail();
         } catch (NoSuchElementException e) {
+            // OK
         }
     }
 
index 0ae958ff11355e7f4d69326418709b6910de12ea..44f90f9884d927df4a20fb939a4ecb4e000334c1 100644 (file)
@@ -47,7 +47,7 @@ public class ThreadPoolExecutorTest {
                 100000, "TestPool", 0 );
     }
 
-    @Test(expected=RejectedExecutionException.class)
+    @Test(expected = RejectedExecutionException.class)
     public void testFastThreadPoolRejectingTask() throws Exception {
 
         executor = SpecialExecutors.newBoundedFastThreadPool( 1, 1, "TestPool" );
@@ -75,7 +75,7 @@ public class ThreadPoolExecutorTest {
                 100000, "TestPool", 0 );
     }
 
-    @Test(expected=RejectedExecutionException.class)
+    @Test(expected = RejectedExecutionException.class)
     public void testCachedThreadRejectingTask() throws Exception {
 
         ExecutorService executor = SpecialExecutors.newBoundedCachedThreadPool( 1, 1, "TestPool" );
@@ -99,8 +99,7 @@ public class ThreadPoolExecutorTest {
 
         this.executor = executor;
 
-        System.out.println( "\nTesting " + executor.getClass().getSimpleName() + " with " +
-                numTasksToRun + " tasks." );
+        System.out.println("\nTesting " + executor.getClass().getSimpleName() + " with " + numTasksToRun + " tasks.");
 
         final CountDownLatch tasksRunLatch = new CountDownLatch( numTasksToRun );
         final ConcurrentMap<Thread, AtomicLong> taskCountPerThread = new ConcurrentHashMap<>();
@@ -127,8 +126,7 @@ public class ThreadPoolExecutorTest {
         stopWatch.stop();
 
         if (!done) {
-            fail( (numTasksToRun - tasksRunLatch.getCount()) + " tasks out of " +
-                   numTasksToRun + " executed" );
+            fail((numTasksToRun - tasksRunLatch.getCount()) + " tasks out of " + numTasksToRun + " executed");
         }
 
         if (threadError.get() != null) {
@@ -181,7 +179,8 @@ public class ThreadPoolExecutorTest {
                     } else if (blockLatch != null) {
                         blockLatch.await();
                     }
-                } catch( InterruptedException e ) {}
+                } catch (InterruptedException e) {
+                }
 
                 if (expThreadPrefix != null) {
                     assertEquals( "Thread name starts with " + expThreadPrefix, true,
@@ -201,7 +200,7 @@ public class ThreadPoolExecutorTest {
                     count.incrementAndGet();
                 }
 
-            } catch( AssertionError e ) {
+            } catch (AssertionError e) {
                 if (threadError != null) {
                     threadError.set( e );
                 }