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

XContentBuilder throws NPE on null Boolean #1853

Closed
sfussenegger opened this issue Apr 11, 2012 · 1 comment
Closed

XContentBuilder throws NPE on null Boolean #1853

sfussenegger opened this issue Apr 11, 2012 · 1 comment

Comments

@sfussenegger
Copy link
Contributor

XContentBuilder.value(Boolean) is the only .value(..) method to not check for null. This is inconsistent and probably not wanted.

Casting explicitly to Object - i.e. calling value(Object) - or invoking nullValue() manually solves the problem.

@sfussenegger
Copy link
Contributor Author

fix:

public XContentBuilder value(Boolean value) throws IOException {
    if (value == null) {
        return nullValue();
    }
    return value(value.booleanValue());
}

@kimchy kimchy closed this as completed in ad07810 Apr 11, 2012
Kami pushed a commit to racker/elasticsearch that referenced this issue May 7, 2012
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants