Skip to content

Ignore empty lines when parsing view results. #265

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rinverardi
Copy link
Contributor

When a view produces no rows, my version of CouchDB (1.6.1) returns an empty line in the rows array:

$ http --pretty none http://.../_view/updates
HTTP/1.1 200 OK
Server: CouchDB/1.6.1 (Erlang OTP/17)
(...)

{"total_rows":0,"offset":0,"rows":[

]}

Trying to iterate over the rows using StreamingViewResult.iterator() fails:

org.ektorp.DbAccessException: com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input at [Source: ; line: 1, column: 0]
        at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270)
        at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3838)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3783)
        at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2381)
        at org.ektorp.StreamingViewResult$StreamingViewResultIterator.hasNext(StreamingViewResult.java:121)
        at java.lang.Iterable.forEach(Iterable.java:74)
        (...)

The attached patch skips the empty lines.

@YannRobert
Copy link
Collaborator

Thank you.
Would you provide some unit test ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants