Skip to content

Ignore empty lines when parsing view results.#265

Open
rinverardi wants to merge 1 commit intohelun:masterfrom
rinverardi:streaming1
Open

Ignore empty lines when parsing view results.#265
rinverardi wants to merge 1 commit intohelun:masterfrom
rinverardi:streaming1

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