Skip to content

Commit

Permalink
Merge branch '2.18'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 28, 2024
2 parents 436e49c + 7af6e97 commit b5308b4
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 199 deletions.
2 changes: 1 addition & 1 deletion avro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ and that's about it, for now.

## Avro Logical Types

Following is an extract from [Logical Types](http://avro.apache.org/docs/current/spec.html#Logical+Types) paragraph in
Following is an extract from [Logical Types](http://avro.apache.org/docs/current/specification/_print/#logical-types) paragraph in
Avro schema specification:
> A logical type is an Avro primitive or complex type with extra attributes to represent a derived type. The attribute
> `logicalType` is always be present for a logical type, and is a string with the name of one of the logical types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ public String nextName() throws JacksonException
throw _wrapIOFailure(e);
}
if (name == null) {
_currToken = _avroContext.currentToken();
_nullSafeUpdateToken(_avroContext.currentToken());
return null;
}
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
return name;
}

Expand All @@ -136,10 +136,10 @@ public boolean nextName(SerializableString sstr) throws JacksonException
throw _wrapIOFailure(e);
}
if (name == null) {
_currToken = _avroContext.currentToken();
_nullSafeUpdateToken(_avroContext.currentToken());
return false;
}
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
String toMatch = sstr.getValue();
if (toMatch == name) {
return true;
Expand Down
90 changes: 45 additions & 45 deletions cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,16 @@ public JsonToken nextToken() throws JacksonException
if (!_streamReadContext.expectMoreValues()) {
_stringRefs.pop();
_streamReadContext = _streamReadContext.getParent();
return (_currToken = JsonToken.END_OBJECT);
return _updateToken(JsonToken.END_OBJECT);
}
return (_currToken = _decodePropertyName());
return _updateToken(_decodePropertyName());
}
} else {
if (!_streamReadContext.expectMoreValues()) {
_stringRefs.pop();
_tagValues.clear();
_streamReadContext = _streamReadContext.getParent();
return (_currToken = JsonToken.END_ARRAY);
return _updateToken(JsonToken.END_ARRAY);
}
}
if (_inputPtr >= _inputEnd) {
Expand Down Expand Up @@ -634,7 +634,7 @@ public JsonToken nextToken() throws JacksonException
if (!_tagValues.isEmpty()) {
return _handleTaggedInt(_tagValues);
}
return (_currToken = JsonToken.VALUE_NUMBER_INT);
return _updateToken(JsonToken.VALUE_NUMBER_INT);
case 1: // negative int
_numTypesValid = NR_INT;
if (lowBits <= 23) {
Expand Down Expand Up @@ -677,20 +677,20 @@ public JsonToken nextToken() throws JacksonException
_invalidToken(ch);
}
}
return (_currToken = JsonToken.VALUE_NUMBER_INT);
return _updateToken(JsonToken.VALUE_NUMBER_INT);

case 2: // byte[]
_typeByte = ch;
_tokenIncomplete = true;
if (!_tagValues.isEmpty()) {
return _handleTaggedBinary(_tagValues);
}
return (_currToken = JsonToken.VALUE_EMBEDDED_OBJECT);
return _updateToken(JsonToken.VALUE_EMBEDDED_OBJECT);

case 3: // String
_typeByte = ch;
_tokenIncomplete = true;
return (_currToken = JsonToken.VALUE_STRING);
return _updateToken(JsonToken.VALUE_STRING);

case 4: // Array
_stringRefs.push(stringrefNamespace);
Expand All @@ -701,11 +701,11 @@ public JsonToken nextToken() throws JacksonException
}
createChildArrayContext(len);
}
return (_currToken = JsonToken.START_ARRAY);
return _updateToken(JsonToken.START_ARRAY);

case 5: // Object
_stringRefs.push(stringrefNamespace);
_currToken = JsonToken.START_OBJECT;
_updateToken(JsonToken.START_OBJECT);
{
int len = _decodeExplicitLength(lowBits);
createChildObjectContext(len);
Expand All @@ -716,43 +716,43 @@ public JsonToken nextToken() throws JacksonException
default: // misc: tokens, floats
switch (lowBits) {
case 20:
return (_currToken = JsonToken.VALUE_FALSE);
return _updateToken(JsonToken.VALUE_FALSE);
case 21:
return (_currToken = JsonToken.VALUE_TRUE);
return _updateToken(JsonToken.VALUE_TRUE);
case 22:
return (_currToken = JsonToken.VALUE_NULL);
return _updateToken(JsonToken.VALUE_NULL);
case 23:
return (_currToken = _decodeUndefinedValue());
return _updateToken(_decodeUndefinedValue());

case 25: // 16-bit float...
// As per [http://stackoverflow.com/questions/5678432/decompressing-half-precision-floats-in-javascript]
{
_numberFloat = (float) _decodeHalfSizeFloat();
_numTypesValid = NR_FLOAT;
}
return (_currToken = JsonToken.VALUE_NUMBER_FLOAT);
return _updateToken(JsonToken.VALUE_NUMBER_FLOAT);
case 26: // Float32
{
_numberFloat = Float.intBitsToFloat(_decode32Bits());
_numTypesValid = NR_FLOAT;
}
return (_currToken = JsonToken.VALUE_NUMBER_FLOAT);
return _updateToken(JsonToken.VALUE_NUMBER_FLOAT);
case 27: // Float64
_numberDouble = Double.longBitsToDouble(_decode64Bits());
_numTypesValid = NR_DOUBLE;
return (_currToken = JsonToken.VALUE_NUMBER_FLOAT);
return _updateToken(JsonToken.VALUE_NUMBER_FLOAT);
case 31: // Break
if (_streamReadContext.inArray()) {
if (!_streamReadContext.hasExpectedLength()) {
_stringRefs.pop();
_streamReadContext = _streamReadContext.getParent();
return (_currToken = JsonToken.END_ARRAY);
return _updateToken(JsonToken.END_ARRAY);
}
}
// Object end-marker can't occur here
_reportUnexpectedBreak();
}
return (_currToken = _decodeSimpleValue(lowBits, ch));
return _updateToken(_decodeSimpleValue(lowBits, ch));
}
}

Expand Down Expand Up @@ -832,7 +832,7 @@ protected String _numberToName(int ch, boolean neg, TagList tags) throws Jackson
protected JsonToken _handleTaggedInt(TagList tags) throws JacksonException {
// For now all we should get is stringref
if (!tags.contains(TAG_ID_STRINGREF)) {
return (_currToken = JsonToken.VALUE_NUMBER_INT);
return _updateToken(JsonToken.VALUE_NUMBER_INT);
}

if (_stringRefs.empty()) {
Expand All @@ -850,7 +850,7 @@ protected JsonToken _handleTaggedInt(TagList tags) throws JacksonException {
Object str = stringRefs.stringRefs.get(_numberInt);
if (str instanceof String) {
_sharedString = (String) str;
return (_currToken = JsonToken.VALUE_STRING);
return _updateToken(JsonToken.VALUE_STRING);
}
_binaryValue = (byte[]) str;
return _handleTaggedBinary(tags);
Expand All @@ -870,7 +870,7 @@ protected JsonToken _handleTaggedBinary(TagList tags) throws JacksonException
// 16-Jan-2024, tatu: Esoteric edge case where we have marked
// `int` as being tokenized
_numTypesValid = NR_UNKNOWN;
return (_currToken = JsonToken.VALUE_EMBEDDED_OBJECT);
return _updateToken(JsonToken.VALUE_EMBEDDED_OBJECT);
}

// First: get the data
Expand All @@ -891,7 +891,7 @@ protected JsonToken _handleTaggedBinary(TagList tags) throws JacksonException
}
_numTypesValid = NR_BIGINT;
_tagValues.clear();
return (_currToken = JsonToken.VALUE_NUMBER_INT);
return _updateToken(JsonToken.VALUE_NUMBER_INT);
}

protected JsonToken _handleTaggedArray(TagList tags, int len) throws JacksonException
Expand All @@ -903,9 +903,9 @@ protected JsonToken _handleTaggedArray(TagList tags, int len) throws JacksonExce

// BigDecimal is the only thing we know for sure
if (!tags.contains(CBORConstants.TAG_DECIMAL_FRACTION)) {
return (_currToken = JsonToken.START_ARRAY);
return _updateToken(JsonToken.START_ARRAY);
}
_currToken = JsonToken.START_ARRAY;
_updateToken(JsonToken.START_ARRAY);

// but has to have length of 2; otherwise we have a problem...
if (len != 2) {
Expand Down Expand Up @@ -941,7 +941,7 @@ protected JsonToken _handleTaggedArray(TagList tags, int len) throws JacksonExce
// which needs to be reset here
_numberBigDecimal = dec;
_numTypesValid = NR_BIGDECIMAL;
return (_currToken = JsonToken.VALUE_NUMBER_FLOAT);
return _updateToken(JsonToken.VALUE_NUMBER_FLOAT);
}

/**
Expand All @@ -960,7 +960,7 @@ protected final boolean _checkNextIsIntInArray(final String typeDesc) throws Jac
_tagValues.clear();
_stringRefs.pop();
_streamReadContext = _streamReadContext.getParent();
_currToken = JsonToken.END_ARRAY;
_updateToken(JsonToken.END_ARRAY);
return false;
}

Expand Down Expand Up @@ -1033,7 +1033,7 @@ protected final boolean _checkNextIsIntInArray(final String typeDesc) throws Jac
}
}
if (tagValues == null) {
_currToken = JsonToken.VALUE_NUMBER_INT;
_updateToken(JsonToken.VALUE_NUMBER_INT);
} else {
_handleTaggedInt(tagValues);
}
Expand Down Expand Up @@ -1080,7 +1080,7 @@ protected final boolean _checkNextIsIntInArray(final String typeDesc) throws Jac
_invalidToken(ch);
}
}
_currToken = JsonToken.VALUE_NUMBER_INT;
_updateToken(JsonToken.VALUE_NUMBER_INT);
return true;

case 2: // byte[]
Expand All @@ -1090,7 +1090,7 @@ protected final boolean _checkNextIsIntInArray(final String typeDesc) throws Jac
}
_typeByte = ch;
_tokenIncomplete = true;
_currToken = _handleTaggedBinary(tagValues);
_updateToken(_handleTaggedBinary(tagValues));
return (_currToken == JsonToken.VALUE_NUMBER_INT);
}

Expand All @@ -1108,7 +1108,7 @@ protected final boolean _checkNextIsEndArray() throws JacksonException
_tagValues.clear();
_stringRefs.pop();
_streamReadContext = _streamReadContext.getParent();
_currToken = JsonToken.END_ARRAY;
_updateToken(JsonToken.END_ARRAY);
return true;
}

Expand Down Expand Up @@ -1171,7 +1171,7 @@ public boolean nextName(SerializableString str) throws JacksonException
if (!_streamReadContext.expectMoreValues()) {
_stringRefs.pop();
_streamReadContext = _streamReadContext.getParent();
_currToken = JsonToken.END_OBJECT;
_updateToken(JsonToken.END_OBJECT);
return false;
}
byte[] nameBytes = str.asQuotedUTF8();
Expand Down Expand Up @@ -1199,7 +1199,7 @@ public boolean nextName(SerializableString str) throws JacksonException
_stringRefs.peek().stringRefs.add(strValue);
}
_streamReadContext.setCurrentName(strValue);
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
return true;
}
if (nameBytes[i] != _inputBuffer[ptr + i]) {
Expand Down Expand Up @@ -1231,7 +1231,7 @@ public String nextName() throws JacksonException
if (!_streamReadContext.expectMoreValues()) {
_stringRefs.pop();
_streamReadContext = _streamReadContext.getParent();
_currToken = JsonToken.END_OBJECT;
_updateToken(JsonToken.END_OBJECT);
return null;
}
// inlined "_decodeFieldName()"
Expand Down Expand Up @@ -1265,13 +1265,13 @@ public String nextName() throws JacksonException
if (!_streamReadContext.hasExpectedLength()) {
_stringRefs.pop();
_streamReadContext = _streamReadContext.getParent();
_currToken = JsonToken.END_OBJECT;
_updateToken(JsonToken.END_OBJECT);
return null;
}
_reportUnexpectedBreak();
}
String name = _decodeNonStringName(ch, _tagValues);
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
return name;
}
final int lenMarker = ch & 0x1F;
Expand Down Expand Up @@ -1312,7 +1312,7 @@ public String nextName() throws JacksonException
_sharedString = name;
}
_streamReadContext.setCurrentName(name);
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
return name;
}
// otherwise just fall back to default handling; should occur rarely
Expand All @@ -1336,7 +1336,7 @@ public boolean nextName(SerializableString str) throws JacksonException
// completed the whole Object?
if (!_streamReadContext.expectMoreValues()) {
_streamReadContext = _streamReadContext.getParent();
_currToken = JsonToken.END_OBJECT;
_updateToken(JsonToken.END_OBJECT);
return false;
}
byte[] nameBytes = str.asQuotedUTF8();
Expand All @@ -1360,7 +1360,7 @@ public boolean nextName(SerializableString str) throws JacksonException
}
_inputPtr = ptr + byteLen;
_streamReadContext.setCurrentName(str.getValue());
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
return true;
}
}
Expand Down Expand Up @@ -1395,7 +1395,7 @@ public int nextNameMatch(PropertyNameMatcher matcher) throws JacksonException
// completed the whole Object?
if (!_streamReadContext.expectMoreValues()) {
_streamReadContext = _streamReadContext.getParent();
_currToken = JsonToken.END_OBJECT;
_updateToken(JsonToken.END_OBJECT);
return PropertyNameMatcher.MATCH_END_OBJECT;
}
// inlined "_decodeFieldName()"
Expand Down Expand Up @@ -1426,7 +1426,7 @@ public int nextNameMatch(PropertyNameMatcher matcher) throws JacksonException
if (ch == 0xFF) { // end-of-object, common
if (!_streamReadContext.hasExpectedLength()) {
_streamReadContext = _streamReadContext.getParent();
_currToken = JsonToken.END_OBJECT;
_updateToken(JsonToken.END_OBJECT);
return PropertyNameMatcher.MATCH_END_OBJECT;
}
_reportUnexpectedBreak();
Expand All @@ -1450,7 +1450,7 @@ public int nextNameMatch(PropertyNameMatcher matcher) throws JacksonException
_inputPtr += lenMarker;
final String name = matcher.nameLookup()[match];
_streamReadContext.setCurrentName(name);
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
return match;
}

Expand Down Expand Up @@ -1479,23 +1479,23 @@ private int _nextFieldDecodeAndAdd(PropertyNameMatcher matcher, int len) throws
_inputPtr += len;
}
_streamReadContext.setCurrentName(name);
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
// 07-Feb-2017, tatu: May actually have match in non-quad part (esp. for case-insensitive)
return matcher.matchName(name);
}

private int _nextNameNonText(PropertyNameMatcher matcher, int ch) throws JacksonException
{
String name = _decodeNonStringName(ch, _tagValues); // NOTE: sets current name too
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
/// 15-Nov-2017, tatu: Is this correct? Copied from `nextName()` but...
return matcher.matchName(name);
}

// For presumable rare case of ""
private int _nextNameEmpty(PropertyNameMatcher matcher) throws JacksonException {
_streamReadContext.setCurrentName("");
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
return matcher.matchName("");
}

Expand All @@ -1514,7 +1514,7 @@ private int _nextNameLong(PropertyNameMatcher matcher, int lenMarker) throws Jac
}
}
_streamReadContext.setCurrentName(name);
_currToken = JsonToken.PROPERTY_NAME;
_updateToken(JsonToken.PROPERTY_NAME);
return matcher.matchName(name);
}

Expand Down
Loading

0 comments on commit b5308b4

Please sign in to comment.