Elasticsearch: Bulk index operation w/o body throws NPE

Created on 16 May 2017  路  2Comments  路  Source: elastic/elasticsearch

Elasticsearch version: 5.4.0

Plugins installed: []

JVM version (java -version):

java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

OS version (uname -a if on a Unix-like system): Windows 7 x64

Description of the problem including expected versus actual behavior:
When calling the _bulk API to index multiple documents, and not using an actual POST body, the server prints a stacktrace of a NullPointerException and responds with a 'null_pointer_exception' error in the response body.
It is clear that this was a bad request, since the actual data which should be indexed, was missing. But it should not result in a NPE but maybe rather a HTTP Bad Request response code. One could even argue that a bulk index without any data is like a bulk index with 0 data, so it could also be regarded a valid call just without any updated documents.

Steps to reproduce:

Provide logs (if relevant):
The following exception stacktrace is printed in the log upon calling the last POST request above:

java.lang.NullPointerException: null
        at org.elasticsearch.action.bulk.BulkRequest.add(BulkRequest.java:318) ~[elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.rest.action.document.RestBulkAction.prepareRequest(RestBulkAction.java:89) ~[elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.rest.BaseRestHandler.handleRequest(BaseRestHandler.java:64) ~[elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:260) ~[elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:199) [elasticsearch-5.4.0.jar:5.4.0]
        at org.elasticsearch.http.netty4.Netty4HttpServerTransport.dispatchRequest(Netty4HttpServerTransport.java:504) [transport-netty4-5.4.0.jar:5.4.0]
        at org.elasticsearch.http.netty4.Netty4HttpRequestHandler.channelRead0(Netty4HttpRequestHandler.java:72) [transport-netty4-5.4.0.jar:5.4.0]
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [netty-transport-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.9.Final.jar:4.1.9.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.9.Final.jar:4.1.9.Final]
:CorInfrREST API :DistributeCRUD

Most helpful comment

I believe this will be fixed by #23497

All 2 comments

I believe this will be fixed by #23497

Thanks for the response. I was searching for a corresponding issue describing the problem to avoid posting a duplicate, however I did not search for a pull request. :)

Was this page helpful?
0 / 5 - 0 ratings