-
Notifications
You must be signed in to change notification settings - Fork 986
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
Fix: Non empty BINARY fields are considered empty #834
Fix: Non empty BINARY fields are considered empty #834
Conversation
…ed as empty no matter what value they actually had. Besides, it has been simplified in a more idiomatic way.
@pfcoperez the change looks good to me, but could you add a unit test case that covers the change? |
5211542
to
42f0752
Compare
@jbaiera Sure. I had to introduce additional changes in order to perform the tests with the provided jackson version. Jackson 1.8.8 Utf8SreamReader lacks the else branch of the following if-sentence at if (_tokenIncomplete) {
try {
_binaryValue = _decodeBase64(b64variant);
} catch (IllegalArgumentException iae) {
throw _constructError("Failed to decode VALUE_STRING as base64 ("+b64variant+"): "+iae.getMessage());
}
/* let's clear incomplete only now; allows for accessing other
* textual content in error cases
*/
_tokenIncomplete = false;
} else { // may actually require conversion...
if (_binaryValue == null) {
@SuppressWarnings("resource")
ByteArrayBuilder builder = _getByteArrayBuilder();
_decodeBase64(getText(), builder, b64variant);
_binaryValue = builder.toByteArray();
}
}
return _binaryValue; In any case, they're related to the unit tests but are is orthogonal to the initial change fixing the bug. |
42f0752
to
049da8c
Compare
Awesome, thanks. I noticed a discrepancy between the LGTM. Thanks again! |
@jbaiera Thanks to you! I wonder whether this PR could be also merged into 2.3.x branches. |
I have a few changes that I was planning on back porting to 2.x, and this is one of them. Should be done by end of day tomorrow. Cheers! |
That's nice! Would it be possible to port Thanks for your great work and being open approach to PRs and suggestions. El mar., 30 ago. 2016 a las 18:12, James Baiera (notifications@github.com)
|
Yep that one is on the list as well. Thanks for the contributions! |
Thank you for submitting a pull request!
Please make sure you have signed our Contributor License Agreement (CLA).
We are not asking you to assign copyright to us, but to give us the right to distribute your code without restriction. We ask this of all contributors in order to assure our users of the origin and continuing existence of the code.
You only need to sign the CLA once.
Prior to this PR, all values for BINARY mapped fields were considered as empty no matter what value they actually had. The problem is that the condition deciding how to manage empty values is incomplete:
On the other hand, this is not critical however, two paths of conditions returning the same value in an if-statement can become a source of bugs if there are changes in the code (what if someone changes the return value at the outer
else
but not when theemptyAsNull && value.isEmpty
is satisfied?). For that, I've rephrased the checks in a more idiomatic Scala style which leverages the nullity check thatOption
's factory provide: