diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/OrderedAwareLinkedHashSet.java b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/OrderedAwareLinkedHashSet.java index aed3c95952..9fb089d229 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/OrderedAwareLinkedHashSet.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/dispatcher/OrderedAwareLinkedHashSet.java @@ -43,8 +43,8 @@ import org.springframework.util.CollectionUtils; */ class OrderedAwareLinkedHashSet extends LinkedHashSet { - OrderComparator comparator = new OrderComparator(); - Lock lock = new ReentrantLock(); + private final OrderComparator comparator = new OrderComparator(); + private final Lock lock = new ReentrantLock(); /** * Every time when Ordered element is added via this method * this Set will be re-sorted, otherwise the element is simply added to the end of the stack. @@ -54,9 +54,9 @@ class OrderedAwareLinkedHashSet extends LinkedHashSet { * Added element must not be null; */ public boolean add(E o){ + Assert.notNull(o,"Can not add NULL object"); lock.lock(); - try { - Assert.notNull(o,"Can not add NULL object"); + try { boolean present = false; if (o instanceof Ordered){ present = this.reinitializeThis(o); @@ -73,9 +73,9 @@ class OrderedAwareLinkedHashSet extends LinkedHashSet { * via call to the reinitializeThis() method */ public boolean addAll(Collection c){ + Assert.notNull(c,"Can not merge with NULL set"); lock.lock(); try { - Assert.notNull(c,"Can not merge with NULL set"); for (E object : c) { this.add(object); } @@ -148,5 +148,4 @@ class OrderedAwareLinkedHashSet extends LinkedHashSet { } return added; } - }