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

Avoid NPE during query parsing #10333

Closed
wants to merge 1 commit into from
Closed

Conversation

masaruh
Copy link
Contributor

@masaruh masaruh commented Mar 31, 2015

Workaround until Jackson is upgraded to 2.6.x.

@masaruh
Copy link
Contributor Author

masaruh commented Mar 31, 2015

In case #10124 isn't feasible...

@s1monw
Copy link
Contributor

s1monw commented Apr 2, 2015

I think this looks good! Can you please sign the CLA for this contribution? @kimchy can you please take another look at this too?

// TODO: Remove this when we upgrade jackson to 2.6.x.
char[] chars = parser.getTextCharacters();
if (chars == null) {
chars = EMPTY_CHARS;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just return new BytesRef() in this case? I don't know if the text characters are null if we can really rely on text offset and length? Maybe a better check, not relying on null check is:

if (parser.getTextLength() == 0) {
    return new BytesRef();
}

@kimchy
Copy link
Member

kimchy commented Apr 2, 2015

I made a small comment here, I think it would be cleaner not to rely on null value for the char array, but use the length and check if its 0. If agreed, +1 on pushing it, thanks @masaruh!

@masaruh masaruh changed the title Workaround for NPE during JSON parsing Queries: Avoid NPE during query parsing Apr 3, 2015
@masaruh
Copy link
Contributor Author

masaruh commented Apr 3, 2015

Thanks @kimchy! Addressed your comment along with a few changes to make tests pass (rebase, include license header, extend ElasticsearchTestCase).

return new BytesRef(CharBuffer.wrap(parser.getTextCharacters(), parser.getTextOffset(), parser.getTextLength()));
// Tentative workaround for https://github.com/elastic/elasticsearch/issues/8629
// TODO: Remove this when we upgrade jackson to 2.6.x.
char[] chars = parser.getTextCharacters();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need this now, and can call parser.getTextCharacters() in line 96?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very true!

@kimchy
Copy link
Member

kimchy commented Apr 5, 2015

@masaruh left another really small comment, other than that, LGTM

Workaround until Jackson is upgraded to 2.6.x.
Fixes elastic#8629.
@masaruh
Copy link
Contributor Author

masaruh commented Apr 6, 2015

Thanks @kimchy. Fixed and merged.

@masaruh masaruh closed this Apr 6, 2015
@masaruh masaruh added :Query DSL and removed review labels Apr 6, 2015
@masaruh masaruh deleted the fix/8629 branch May 14, 2015 00:23
@clintongormley clintongormley changed the title Queries: Avoid NPE during query parsing Avoid NPE during query parsing Jun 8, 2015
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query DSL labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories v1.5.1 v1.6.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants