diff --git a/src/main/java/org/takes/misc/Select.java b/src/main/java/org/takes/misc/Select.java index b45472ba4..490ac4470 100644 --- a/src/main/java/org/takes/misc/Select.java +++ b/src/main/java/org/takes/misc/Select.java @@ -77,33 +77,28 @@ public Iterator iterator() { * *

This class is NOT thread-safe. */ - private static class SelectIterator implements Iterator { - + private static final class SelectIterator implements Iterator { /** * The iterator to reflect the traverse state. */ private final transient Iterator iterator; - /** * The condition to filter the elements in the iterator. */ private final transient Condition condition; - /** * The buffer storing the objects of the iterator. */ private final transient Queue buffer = new LinkedList(); - /** * Ctor. ConcatIterator traverses the element. * @param itr Iterator of the original iterable * @param cond Condition to filter out elements */ - public SelectIterator(final Iterator itr, final Condition cond) { + SelectIterator(final Iterator itr, final Condition cond) { this.condition = cond; this.iterator = itr; } - @Override public boolean hasNext() { if (this.buffer.isEmpty()) { @@ -117,7 +112,6 @@ public boolean hasNext() { } return !this.buffer.isEmpty(); } - @Override public E next() { if (!this.hasNext()) { @@ -127,7 +121,6 @@ public E next() { } return this.buffer.poll(); } - @Override public void remove() { throw new UnsupportedOperationException( diff --git a/src/main/java/org/takes/rs/RsWithStatus.java b/src/main/java/org/takes/rs/RsWithStatus.java index a6baec97f..a41e5f250 100644 --- a/src/main/java/org/takes/rs/RsWithStatus.java +++ b/src/main/java/org/takes/rs/RsWithStatus.java @@ -30,7 +30,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicBoolean; import lombok.EqualsAndHashCode; import org.takes.Response; import org.takes.misc.Concat; @@ -121,10 +120,9 @@ private static Iterable head(final Response origin, new Select( origin.head(), new Condition() { - private final AtomicBoolean fit = new AtomicBoolean(false); @Override - public boolean fits(final String element) { - return this.fit.getAndSet(true); + public boolean fits(final String item) { + return !item.startsWith("HTTP/"); } } ) diff --git a/src/test/java/org/takes/rs/RsWithStatusTest.java b/src/test/java/org/takes/rs/RsWithStatusTest.java index ab9d5c7ff..e70cff9f3 100644 --- a/src/test/java/org/takes/rs/RsWithStatusTest.java +++ b/src/test/java/org/takes/rs/RsWithStatusTest.java @@ -79,11 +79,11 @@ public void addsStatusMultipleTimes() throws IOException { ); MatcherAssert.assertThat( response.head(), - Matchers.iterableWithSize(3) + Matchers.iterableWithSize(1) ); MatcherAssert.assertThat( response.head(), - Matchers.iterableWithSize(3) + Matchers.iterableWithSize(1) ); } }