Skip to content

Commit bdf400e

Browse files
committed
Add release notes, minor tweaks
1 parent 03b355e commit bdf400e

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,10 +1939,15 @@ private final byte[] _getBinaryFromString(Base64Variant variant) throws IOExcept
19391939
* and the token is reported as {@link JsonToken#VALUE_NULL}.
19401940
*
19411941
* @return {@code true} if current token is an `undefined`, {@code false} otherwise
1942+
*
19421943
* @since 2.20
19431944
*/
19441945
public boolean isUndefined() {
1945-
return (_inputBuffer[_inputPtr - 1] & 0xFF) == SIMPLE_VALUE_UNDEFINED;
1946+
if ((_currToken == JsonToken.VALUE_NULL) || (_currToken == JsonToken.VALUE_NULL)) {
1947+
return (_inputBuffer != null)
1948+
&& (_inputBuffer[_inputPtr - 1] & 0xFF) == SIMPLE_VALUE_UNDEFINED;
1949+
}
1950+
return false;
19461951
}
19471952

19481953
/*
@@ -3686,20 +3691,20 @@ private final static long _long(int i1, int i2)
36863691
* Helper method to encapsulate details of handling of mysterious `undefined` value
36873692
* that is allowed to be used as something encoder could not handle (as per spec),
36883693
* whatever the heck that should be.
3689-
*
36903694
* <p>
3691-
* For backward compatibility with Jackson 2.9.6 to 2.19, this value is decoded
3695+
* For backward compatibility with Jackson 2.10 to 2.19, this value is decoded
36923696
* as {@link JsonToken#VALUE_NULL} by default.
36933697
* <p>
36943698
*
36953699
* since 2.20 If {@link CBORParser.Feature#HANDLE_UNDEFINED_AS_EMBEDDED_OBJECT} is enabled,
36963700
* the value will instead be decoded as {@link JsonToken#VALUE_EMBEDDED_OBJECT}
36973701
* with an embedded value of {@code null}.
36983702
*
3699-
* @since 2.9.6
3703+
* @since 2.10
37003704
*/
37013705
protected JsonToken _decodeUndefinedValue() {
3702-
if (CBORParser.Feature.HANDLE_UNDEFINED_AS_EMBEDDED_OBJECT.enabledIn(_formatFeatures)) {
3706+
if (Feature.HANDLE_UNDEFINED_AS_EMBEDDED_OBJECT.enabledIn(_formatFeatures)) {
3707+
_binaryValue = null; // should be clear but just in case
37033708
return JsonToken.VALUE_EMBEDDED_OBJECT;
37043709
}
37053710
return JsonToken.VALUE_NULL;

release-notes/CREDITS-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ Brian Gruber (@bgruber)
391391
(2.20.0)
392392

393393
Fawzi Essam (@iifawzi)
394+
* Contributed implementation of #137: (cbor) Allow exposing CBOR "undefined" value as
395+
`JsonToken.VALUE_EMBEDDED_OBJECT`; with embedded value of `null`
396+
(2.20.0)
394397
* Contributed fix for #431: (cbor) Negative `BigInteger` values not encoded/decoded
395398
correctly
396399
(2.20.0)

release-notes/VERSION-2.x

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Active maintainers:
1616

1717
2.20.0 (not yet released)
1818

19+
#137: (cbor) Allow exposing CBOR "undefined" value as `JsonToken.VALUE_EMBEDDED_OBJECT`;
20+
with embedded value of `null`
21+
(implementation contributed by Fawzi E)
22+
1923
#431: (cbor) Negative `BigInteger` values not encoded/decoded correctly
2024
(reported by Brian G)
2125
(fix contributed by Fawzi E)

0 commit comments

Comments
 (0)