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

Delete index Java REST API request throws NPE while parsing DeleteResponse #35297

Closed
serhiy opened this issue Nov 6, 2018 · 3 comments · Fixed by #35314
Closed

Delete index Java REST API request throws NPE while parsing DeleteResponse #35297

serhiy opened this issue Nov 6, 2018 · 3 comments · Fixed by #35314
Assignees
Labels
>bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. good first issue low hanging fruit

Comments

@serhiy
Copy link

serhiy commented Nov 6, 2018

Elasticsearch version: Version: 5.6.12, Build: cfe3d9f/2018-09-10T20:12:43.732Z, JVM: 1.8.0_191

Plugins installed: none

JVM version: OpenJDK 1.8.0_191

OS version: CentOS 7

Description of the problem including expected versus actual behavior:
Delete index Java REST API request throws NPE while parsing DeleteResponse (tested on both embedded server and development infrastructure running Elasticsearch service)
We are using 5.6.12 Java REST API version, from what I can tell the problem might be in the line 87 of DeleteResponse class, where the method longValue() on version object is called (debugging suggests that version can be null).

Steps to reproduce:

  1. Create an Index
XContentBuilder  builder = XContentFactory.jsonBuilder().startObject().startObject("settings").value(indexSettings).endObject().startObject("mappings").value("{}").endObject().endObject();
IndexRequest indexRequest = new IndexRequest(indexName, "", "");
indexRequest.source(builder);
indexRequest.create(true);
client.index(indexRequest);
  1. Check that index exists in ES
  2. Delete index
DeleteRequest deleteRequest = new DeleteRequest(indexName, "", "");
DeleteResponse deleteResponse = client.getClient().delete(deleteRequest);

Provide logs (if relevant):
java.io.IOException: Unable to parse response body for Response{requestLine=DELETE /deletion_test_index?timeout=1m HTTP/1.1, host=http://some-host.com:9200, response=HTTP/1.1 200 OK}
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:415) ~[elasticsearch-rest-high-level-client-5.6.12.jar:5.6.12]
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:382) ~[elasticsearch-rest-high-level-client-5.6.12.jar:5.6.12]
at org.elasticsearch.client.RestHighLevelClient.delete(RestHighLevelClient.java:303) ~[elasticsearch-rest-high-level-client-5.6.12.jar:5.6.12]
at server.elasticsearch.IndexManager.delete(IndexManager.java:140) ~[classes/:na]
at server.elasticsearch.IndexManagerTest.deleteIndexTest(IndexManagerTest.java:63) [test-classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12]
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12]
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) [junit-4.12.jar:4.12]
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) [junit-4.12.jar:4.12]
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
at org.junit.runner.JUnitCore.run(JUnitCore.java:137) [junit-4.12.jar:4.12]
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) [junit-rt.jar:na]
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) [junit-rt.jar:na]
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) [junit-rt.jar:na]
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) [junit-rt.jar:na]
Caused by: java.lang.NullPointerException: null
at org.elasticsearch.action.delete.DeleteResponse$Builder.build(DeleteResponse.java:115) ~[elasticsearch-5.6.12.jar:5.6.12]
at org.elasticsearch.action.delete.DeleteResponse.fromXContent(DeleteResponse.java:81) ~[elasticsearch-5.6.12.jar:5.6.12]
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:526) ~[elasticsearch-rest-high-level-client-5.6.12.jar:5.6.12]
at org.elasticsearch.client.RestHighLevelClient.lambda$performRequestAndParseEntity$2(RestHighLevelClient.java:382) ~[elasticsearch-rest-high-level-client-5.6.12.jar:5.6.12]
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:413) ~[elasticsearch-rest-high-level-client-5.6.12.jar:5.6.12]
... 28 common frames omitted

@vladimirdolzhenko vladimirdolzhenko added >bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. labels Nov 6, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@vladimirdolzhenko
Copy link
Contributor

vladimirdolzhenko commented Nov 6, 2018

root cause: new DeleteRequest(indexName, "", "") effectively faces Delete Index API that responds with {acknowledged=true} while DeleteRequest is Delete documents API.

Have to improve DeleteRequest#validate.

Looks like ExplainRequest, GetRequest and UpdateRequest have same problem.

@vladimirdolzhenko vladimirdolzhenko added the good first issue low hanging fruit label Nov 6, 2018
@javanna
Copy link
Member

javanna commented Nov 6, 2018

root cause: new DeleteRequest(indexName, "", "") effectively faces Delete Index API that responds with {acknowledged=true} while DeleteRequest is Delete documents API.

oh boy this is a very bad bug.

@vladimirdolzhenko vladimirdolzhenko self-assigned this Nov 6, 2018
vladimirdolzhenko pushed a commit to vladimirdolzhenko/elasticsearch that referenced this issue Nov 6, 2018
vladimirdolzhenko added a commit that referenced this issue Nov 7, 2018
vladimirdolzhenko added a commit that referenced this issue Nov 7, 2018
…ation for null and/or empty id/type (#35314)

Closes #35297

(cherry picked from commit a467a81)
vladimirdolzhenko added a commit that referenced this issue Nov 7, 2018
…ation for null and/or empty id/type (#35314)

Closes #35297

(cherry picked from commit a467a81)
vladimirdolzhenko added a commit that referenced this issue Nov 7, 2018
vladimirdolzhenko added a commit that referenced this issue Nov 7, 2018
…ation for null and/or empty id/type (#35314)

Closes #35297

(cherry picked from commit a467a81)
pgomulka pushed a commit to pgomulka/elasticsearch that referenced this issue Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. good first issue low hanging fruit
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants