diff --git a/src/main/java/org/apache/commons/collections4/deque/BlockingDeque.java b/src/main/java/org/apache/commons/collections4/deque/BlockingDeque.java index 9cda31f38..a85fd3075 100644 --- a/src/main/java/org/apache/commons/collections4/deque/BlockingDeque.java +++ b/src/main/java/org/apache/commons/collections4/deque/BlockingDeque.java @@ -40,6 +40,10 @@ import java.util.concurrent.locks.ReentrantLock; * @since 4.5 */ public class BlockingDeque extends AbstractCollection implements Deque, Serializable { + + /** Serialization version */ + private static final long serialVersionUID = 3961982897426944557L; + final Deque deque; final ReentrantLock lock = new ReentrantLock(); @@ -116,7 +120,7 @@ public class BlockingDeque extends AbstractCollection implements Deque, lock.lock(); try { boolean r; - if ((r = deque.offerFirst(e)) == true) + if (r = deque.offerFirst(e)) notEmpty.signal(); return r; } catch (Exception ex) { @@ -139,7 +143,7 @@ public class BlockingDeque extends AbstractCollection implements Deque, lock.lock(); try { boolean r; - if ((r = deque.offerLast(e)) == true) + if (r = deque.offerLast(e)) notEmpty.signal(); return r; } catch (Exception ex) { @@ -330,7 +334,7 @@ public class BlockingDeque extends AbstractCollection implements Deque, lock.lock(); try { boolean r; - if ((r = deque.removeFirstOccurrence(o)) == true) + if (r = deque.removeFirstOccurrence(o)) notEmpty.signal(); return r; } finally { @@ -343,7 +347,7 @@ public class BlockingDeque extends AbstractCollection implements Deque, lock.lock(); try { boolean r; - if ((r = deque.removeLastOccurrence(o)) == true) + if (r = deque.removeLastOccurrence(o)) notEmpty.signal(); return r; } finally { @@ -412,7 +416,7 @@ public class BlockingDeque extends AbstractCollection implements Deque, lock.lock(); try { boolean r; - if ((r = deque.addAll(c)) == true) + if (r = deque.addAll(c)) notEmpty.signalAll(); return r; } finally { @@ -425,7 +429,7 @@ public class BlockingDeque extends AbstractCollection implements Deque, lock.lock(); try { boolean r; - if ((r = deque.removeAll(c)) == true) + if (r = deque.removeAll(c)) notFull.signalAll(); return r; } finally { diff --git a/src/main/java/org/apache/commons/collections4/deque/CircularDeque.java b/src/main/java/org/apache/commons/collections4/deque/CircularDeque.java index a867e5921..702c0ae45 100644 --- a/src/main/java/org/apache/commons/collections4/deque/CircularDeque.java +++ b/src/main/java/org/apache/commons/collections4/deque/CircularDeque.java @@ -56,6 +56,9 @@ import java.util.Iterator; public class CircularDeque extends AbstractCollection implements Deque, BoundedCollection, Serializable { + /** Serialization version */ + private static final long serialVersionUID = 6013343683263686185L; + /** Underlying storage array. */ private transient E[] elements; @@ -469,7 +472,7 @@ public class CircularDeque extends AbstractCollection System.arraycopy(elements, i + 1, elements, i, back); tail--; } - } else if (head >tail) { + } else if (head > tail) { if (i > head) { System.arraycopy(elements, head, elements, head + 1, front); head++; diff --git a/src/main/java/org/apache/commons/collections4/deque/PredicatedDeque.java b/src/main/java/org/apache/commons/collections4/deque/PredicatedDeque.java index 003d0d6b2..a02c5005e 100644 --- a/src/main/java/org/apache/commons/collections4/deque/PredicatedDeque.java +++ b/src/main/java/org/apache/commons/collections4/deque/PredicatedDeque.java @@ -40,6 +40,10 @@ import java.util.Iterator; * @since 4.5 */ public class PredicatedDeque extends PredicatedCollection implements Deque { + + /** Serialization version */ + private static final long serialVersionUID = 7027705675493389763L; + /** * Factory method to create a predicated (validating) deque. *

diff --git a/src/main/java/org/apache/commons/collections4/deque/SynchronizedDeque.java b/src/main/java/org/apache/commons/collections4/deque/SynchronizedDeque.java index f2e2a959c..e750f4cd8 100644 --- a/src/main/java/org/apache/commons/collections4/deque/SynchronizedDeque.java +++ b/src/main/java/org/apache/commons/collections4/deque/SynchronizedDeque.java @@ -34,7 +34,7 @@ import java.util.Iterator; public class SynchronizedDeque extends SynchronizedCollection implements Deque { /** Serialization version */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 4565577797338001569L; /** * Factory method to create a synchronized deque. diff --git a/src/main/java/org/apache/commons/collections4/deque/TransformedDeque.java b/src/main/java/org/apache/commons/collections4/deque/TransformedDeque.java index d2843c328..dd480ebe5 100644 --- a/src/main/java/org/apache/commons/collections4/deque/TransformedDeque.java +++ b/src/main/java/org/apache/commons/collections4/deque/TransformedDeque.java @@ -39,7 +39,7 @@ import java.util.Iterator; public class TransformedDeque extends TransformedCollection implements Deque { /** Serialization version */ - private static final long serialVersionUID = -7901091318986132033L; + private static final long serialVersionUID = 7959728067506831816L; /** * Factory method to create a transforming deque. @@ -76,7 +76,7 @@ public class TransformedDeque extends TransformedCollection implements Deq */ public static TransformedDeque transformedDeque(final Deque deque, final Transformer transformer) { - // throws IAE if deque or transformer is null + // throws NullPointerException if deque or transformer is null final TransformedDeque decorated = new TransformedDeque<>(deque, transformer); if (deque.size() > 0) { @SuppressWarnings("unchecked") // deque is type diff --git a/src/test/java/org/apache/commons/collections4/deque/AbstractDequeTest.java b/src/test/java/org/apache/commons/collections4/deque/AbstractDequeTest.java index 5cb33b28b..a5c62c245 100644 --- a/src/test/java/org/apache/commons/collections4/deque/AbstractDequeTest.java +++ b/src/test/java/org/apache/commons/collections4/deque/AbstractDequeTest.java @@ -750,8 +750,8 @@ public abstract class AbstractDequeTest extends AbstractCollectionTest { return; } - final byte[] objekt = writeExternalFormToBytes((Serializable) deque); - final Deque deque2 = (Deque) readExternalFormFromBytes(objekt); + final byte[] object = writeExternalFormToBytes((Serializable) deque); + final Deque deque2 = (Deque) readExternalFormFromBytes(object); assertEquals("Both deques are empty", 0, deque.size()); assertEquals("Both deques are empty", 0, deque2.size()); @@ -765,8 +765,8 @@ public abstract class AbstractDequeTest extends AbstractCollectionTest { return; } - final byte[] objekt = writeExternalFormToBytes((Serializable) deque); - final Deque deque2 = (Deque) readExternalFormFromBytes(objekt); + final byte[] object = writeExternalFormToBytes((Serializable) deque); + final Deque deque2 = (Deque) readExternalFormFromBytes(object); assertEquals("Both deques are same size", size, deque.size()); assertEquals("Both deques are same size", size, deque2.size()); diff --git a/src/test/java/org/apache/commons/collections4/deque/CircularDequeTest.java b/src/test/java/org/apache/commons/collections4/deque/CircularDequeTest.java index 8175aeda2..544d03d22 100644 --- a/src/test/java/org/apache/commons/collections4/deque/CircularDequeTest.java +++ b/src/test/java/org/apache/commons/collections4/deque/CircularDequeTest.java @@ -81,10 +81,10 @@ public class CircularDequeTest extends AbstractDequeTest { public void testConstructorException1() { try { new CircularDeque(0); + fail(); } catch (final IllegalArgumentException ex) { - return; + } - fail(); } /** @@ -93,10 +93,10 @@ public class CircularDequeTest extends AbstractDequeTest { public void testConstructorException2() { try { new CircularDeque(-20); + fail(); } catch (final IllegalArgumentException ex) { - return; + } - fail(); } /** @@ -105,10 +105,10 @@ public class CircularDequeTest extends AbstractDequeTest { public void testConstructorException3() { try { new CircularDeque(null); + fail(); } catch (final NullPointerException ex) { - return; + } - fail(); } /**