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

Putting a mapping with an empty request body throws a NullPointerException #7536

dtdesign opened this issue Sep 2, 2014 · 3 comments


None yet
5 participants
Copy link

commented Sep 2, 2014

I have been struggling with an issue lately caused by my own fault of providing a valid request body when attempting to add a mapping to an existing index. Attempting to do so will yield a NullPointerException:

[2014-09-01 20:08:31,486][DEBUG][action.admin.indices.mapping.put] [Prototype] failed to put mappings on indices [[my_index]], type [my_type]
    at org.elasticsearch.common.xcontent.XContentFactory.xContent(
    at org.elasticsearch.common.xcontent.XContentHelper.convertToMap(
    at org.elasticsearch.common.xcontent.XContentHelper.convertToMap(
    at org.elasticsearch.index.mapper.DocumentMapperParser.parseCompressed(
    at org.elasticsearch.index.mapper.MapperService.parse(
    at org.elasticsearch.index.mapper.MapperService.parse(
    at org.elasticsearch.cluster.metadata.MetaDataMappingService$5.execute(
    at org.elasticsearch.cluster.service.InternalClusterService$
    at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$
    at java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.util.concurrent.ThreadPoolExecutor$

The issues is caused by which returns null if the input stream is empty. While this is fine, the real problem lies in XContentHelper.convertToMap() which does not properly check for null.

To be fair, this isn't really a bug and I'm more like asking to yield a proper exception in case a developer is as dumb as me and fails to provide a proper request body.

@s1monw s1monw added adoptme labels Sep 2, 2014


This comment has been minimized.

Copy link

commented Sep 4, 2014

Could you provide some examples of the messages you used?


This comment has been minimized.

Copy link

commented Sep 5, 2014

@cfontes The request was PUT, message body had a length of 0.


This comment has been minimized.

Copy link

commented Sep 5, 2014

Found the problem and fixed. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.