Skip to content

Commit

Permalink
yegor256#336 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Jun 8, 2015
1 parent 6eb2337 commit fa66e82
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
11 changes: 2 additions & 9 deletions src/main/java/org/takes/misc/Select.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,33 +77,28 @@ public Iterator<T> iterator() {
*
* <p>This class is NOT thread-safe.
*/
private static class SelectIterator<E> implements Iterator<E> {

private static final class SelectIterator<E> implements Iterator<E> {
/**
* The iterator to reflect the traverse state.
*/
private final transient Iterator<E> iterator;

/**
* The condition to filter the elements in the iterator.
*/
private final transient Condition<E> condition;

/**
* The buffer storing the objects of the iterator.
*/
private final transient Queue<E> buffer = new LinkedList<E>();

/**
* Ctor. ConcatIterator traverses the element.
* @param itr Iterator of the original iterable
* @param cond Condition to filter out elements
*/
public SelectIterator(final Iterator<E> itr, final Condition<E> cond) {
SelectIterator(final Iterator<E> itr, final Condition<E> cond) {
this.condition = cond;
this.iterator = itr;
}

@Override
public boolean hasNext() {
if (this.buffer.isEmpty()) {
Expand All @@ -117,7 +112,6 @@ public boolean hasNext() {
}
return !this.buffer.isEmpty();
}

@Override
public E next() {
if (!this.hasNext()) {
Expand All @@ -127,7 +121,6 @@ public E next() {
}
return this.buffer.poll();
}

@Override
public void remove() {
throw new UnsupportedOperationException(
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/takes/rs/RsWithStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,10 +120,9 @@ private static Iterable<String> head(final Response origin,
new Select<String>(
origin.head(),
new Condition<String>() {
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/");
}
}
)
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/takes/rs/RsWithStatusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public void addsStatusMultipleTimes() throws IOException {
);
MatcherAssert.assertThat(
response.head(),
Matchers.<String>iterableWithSize(3)
Matchers.<String>iterableWithSize(1)
);
MatcherAssert.assertThat(
response.head(),
Matchers.<String>iterableWithSize(3)
Matchers.<String>iterableWithSize(1)
);
}
}

0 comments on commit fa66e82

Please sign in to comment.