Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] remove() method on ResourceIterator throws wrong Exception. #4984

Closed
bHacklv opened this issue Jul 15, 2015 · 0 comments
Closed

[Bug] remove() method on ResourceIterator throws wrong Exception. #4984

bHacklv opened this issue Jul 15, 2015 · 0 comments

Comments

@bHacklv
Copy link

bHacklv commented Jul 15, 2015

Hi,

remove() method on **ResourceIterator* that was constructed from calling columnAs() throws wrong Exception - IllegalStateException
Has to be UnsupportedOperationException

My code example:

try (final Result result = dbSteps().execute(MATCH_N_RETURN_N_TITLE_N_AUTHOR)) {
    assertThat(result.hasNext()).isTrue();
    try (final ResourceIterator<Object> objectResourceIterator = result.columnAs("n.title")) {
        assertThat(objectResourceIterator.hasNext()).isTrue();
        objectResourceIterator.remove(); \\ <--- throws wrong exception
     }
}

Same remove() operation if called on result.remove() throws correct UnsupportedOperationException.

This error is due to you are reconstructing ResourceIterator into Collections.emptyIterator:

private trait WrappingResourceIterator[T] extends ResourceIterator[T] {
    def remove() { Collections.emptyIterator[T]().remove() }
    def close() { self.close() }
  }

and then delegating remove() call to emptyIterator...
IllegalStateException is legit exception for empty Iterator (as of java.util.Collections.java), however my columnAs() does return results and shouldn't be reconstructed into empty rItr...

@systay systay closed this as completed in 561be62 Oct 8, 2015
systay added a commit that referenced this issue Oct 8, 2015
…tion_on_column_as

Fix #4984 - UnsupportedOperationException on ResourceIterator::remove()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant