Skip to content

Commit 7732bbb

Browse files
authored
Merge branch '2.19' into sugmanue/improve-ascii-performace
2 parents 2940ef9 + 5888efa commit 7732bbb

File tree

11 files changed

+112
-18
lines changed

11 files changed

+112
-18
lines changed

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroTypeIdResolver.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,24 @@ public class AvroTypeIdResolver extends ClassNameIdResolver
2929

3030
public AvroTypeIdResolver(JavaType baseType, TypeFactory typeFactory,
3131
PolymorphicTypeValidator ptv,
32-
Collection<NamedType> subTypes) {
33-
this(baseType, typeFactory, ptv);
32+
Collection<NamedType> subTypes)
33+
{
34+
super(baseType, typeFactory, subTypes, ptv);
3435
if (subTypes != null) {
3536
for (NamedType namedType : subTypes) {
36-
registerSubtype(namedType.getType(), namedType.getName());
37+
//registerSubtype(namedType.getType(), namedType.getName());
38+
_idTypes.put(namedType.getName(), namedType.getType());
3739
}
3840
}
3941
}
4042

41-
public AvroTypeIdResolver(JavaType baseType, TypeFactory typeFactory,
42-
PolymorphicTypeValidator ptv) {
43-
super(baseType, typeFactory, ptv);
44-
}
45-
43+
/*// Not used as of Jackson 2.19
4644
@Override
4745
public void registerSubtype(Class<?> type, String name) {
4846
_idTypes.put(name, type);
4947
// _typeIds.put(type, name);
5048
}
49+
*/
5150

5251
@Override
5352
protected JavaType _typeFromId(String id, DatabindContext ctxt) throws IOException {

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/mapper/NumberBeanTest.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
import org.junit.jupiter.api.Test;
88

9+
import com.fasterxml.jackson.annotation.JsonCreator;
910
import com.fasterxml.jackson.annotation.JsonUnwrapped;
11+
import com.fasterxml.jackson.annotation.JsonValue;
1012
import com.fasterxml.jackson.core.JsonParser.NumberType;
1113
import com.fasterxml.jackson.core.JsonToken;
1214
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -47,6 +49,26 @@ static class NestedBigDecimalHolder2784 {
4749
public BigDecimalHolder2784 holder;
4850
}
4951

52+
// for [databind#4917]
53+
static class DeserializationIssue4917 {
54+
public DecimalHolder4917 decimalHolder;
55+
public double number;
56+
}
57+
58+
static class DecimalHolder4917 {
59+
@JsonValue
60+
BigDecimal value;
61+
62+
private DecimalHolder4917(BigDecimal value) {
63+
this.value = value;
64+
}
65+
66+
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
67+
static DecimalHolder4917 of(BigDecimal value) {
68+
return new DecimalHolder4917(value);
69+
}
70+
}
71+
5072
/*
5173
/**********************************************************
5274
/* Test methods
@@ -256,4 +278,20 @@ public void testBigDecimalWithBuffering() throws Exception
256278
NestedBigDecimalHolder2784.class);
257279
assertEquals(VALUE, result.holder.value);
258280
}
281+
282+
// [databind#4917]
283+
@Test
284+
public void testIssue4917() throws Exception {
285+
final String bd = "100.00";
286+
final double d = 50.0;
287+
final DeserializationIssue4917 value = new DeserializationIssue4917();
288+
value.decimalHolder = DecimalHolder4917.of(new BigDecimal(bd));
289+
value.number = d;
290+
final byte[] data = MAPPER.writeValueAsBytes(value);
291+
292+
final DeserializationIssue4917 result = MAPPER.readValue(
293+
data, DeserializationIssue4917.class);
294+
assertEquals(value.decimalHolder.value, result.decimalHolder.value);
295+
assertEquals(value.number, result.number);
296+
}
259297
}

ion/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ tree model)
3939
<dependency>
4040
<groupId>com.amazon.ion</groupId>
4141
<artifactId>ion-java</artifactId>
42-
<version>1.11.9</version>
42+
<version>1.11.10</version>
4343
</dependency>
4444

4545
<!-- Extends Jackson core, databind -->

ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ private long _getLongValue() throws IOException {
414414
try {
415415
if (this.getNumberType() == NumberType.BIG_INTEGER) {
416416
BigInteger bigInteger = _reader.bigIntegerValue();
417-
if (BI_MIN_INT.compareTo(bigInteger) > 0 || BI_MAX_INT.compareTo(bigInteger) < 0) {
418-
this.reportOverflowLong();
417+
if (BI_MIN_LONG.compareTo(bigInteger) > 0 || BI_MAX_LONG.compareTo(bigInteger) < 0) {
418+
reportOverflowLong();
419419
}
420420
return bigInteger.longValue();
421421
} else {

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonNumberOverflowTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import org.hamcrest.Matchers;
66
import org.junit.jupiter.api.Test;
77

8+
import com.fasterxml.jackson.core.JsonParser;
9+
import com.fasterxml.jackson.core.JsonToken;
810
import com.fasterxml.jackson.core.exc.InputCoercionException;
911

1012
import static org.hamcrest.MatcherAssert.assertThat;
@@ -72,4 +74,15 @@ private void _testLongCoercionFail(BigInteger input) throws Exception
7274
}
7375
}
7476

77+
// [dataformats-binary#569]: incorrect overflow fail for long values (from BigInteger)
78+
@Test
79+
public void testLongAsBigIntegerSize() throws Exception {
80+
// Note: Values: Long.MAX_VALUE through Long.MAX_VALUE -7 are considered LONG by Ion.
81+
BigInteger bigIntLongValue = new BigInteger(Long.MAX_VALUE + "").subtract(BigInteger.TEN);
82+
IonParser bigIntLongParser = (IonParser) new IonFactory().createParser(bigIntLongValue.toString());
83+
assertEquals(JsonToken.VALUE_NUMBER_INT, bigIntLongParser.nextToken());
84+
assertEquals(JsonParser.NumberType.BIG_INTEGER, bigIntLongParser.getNumberType());
85+
assertEquals(JsonParser.NumberTypeFP.UNKNOWN, bigIntLongParser.getNumberTypeFP());
86+
assertEquals(bigIntLongValue.longValue(), bigIntLongParser.getLongValue());
87+
}
7588
}

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/PolymorphicRoundtripTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ protected TypeIdResolver defaultIdResolver(MapperConfig<?> config, JavaType base
292292
config.getPolymorphicTypeValidator());
293293
} else {
294294
return new ClassNameIdResolver(baseType, config.getTypeFactory(),
295-
config.getPolymorphicTypeValidator());
295+
null, config.getPolymorphicTypeValidator());
296296
}
297297
}
298298
}
@@ -303,7 +303,7 @@ class MultipleClassNameIdResolver extends ClassNameIdResolver implements Multipl
303303

304304
MultipleClassNameIdResolver(JavaType baseType, TypeFactory typeFactory,
305305
PolymorphicTypeValidator ptv) {
306-
super(baseType, typeFactory, ptv);
306+
super(baseType, typeFactory, null, ptv);
307307
}
308308

309309
@Override

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/polymorphism/IonAnnotationTypeDeserializerWithClassNameAnnotationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ static class ClassNameIonAnnotationIntrospector extends IonAnnotationIntrospecto
102102

103103
@Override
104104
protected TypeIdResolver defaultIdResolver(MapperConfig<?> config, JavaType baseType) {
105-
return new ClassNameIdResolver(baseType, config.getTypeFactory(), config.getPolymorphicTypeValidator());
105+
return new ClassNameIdResolver(baseType, config.getTypeFactory(),
106+
null, config.getPolymorphicTypeValidator());
106107
}
107108
}
108109

release-notes/VERSION-2.x

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ Active maintainers:
3535
#547: (all) JSTEP-10: Unify testing structure/tools
3636
(contributed by Joo-Hyuk K)
3737

38+
2.18.4 (not yet released)
39+
40+
#569: (ion) `IonParser` fails to parse some `long` values saying
41+
they are out of range when they are not
42+
(reported, fix suggested by @seadbrane)
43+
- (ion) Upgrade `ion-java` to 1.11.10 (from 1.11.9)
44+
3845
2.18.3 (28-Feb-2025)
3946

4047
#541: (cbor, protobuf, smile) `SmileParser.getValueAsString()` FIELD_NAME bug

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/mapper/NumberBeanTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66

77
import org.junit.jupiter.api.Test;
88

9+
import com.fasterxml.jackson.annotation.JsonCreator;
910
import com.fasterxml.jackson.annotation.JsonUnwrapped;
11+
import com.fasterxml.jackson.annotation.JsonValue;
12+
1013
import com.fasterxml.jackson.core.JsonParser.NumberType;
1114
import com.fasterxml.jackson.core.JsonToken;
15+
1216
import com.fasterxml.jackson.databind.ObjectMapper;
1317
import com.fasterxml.jackson.dataformat.smile.*;
1418

@@ -41,6 +45,26 @@ static class NestedBigDecimalHolder2784 {
4145
public BigDecimalHolder2784 holder;
4246
}
4347

48+
// for [databind#4917]
49+
static class DeserializationIssue4917 {
50+
public DecimalHolder4917 decimalHolder;
51+
public double number;
52+
}
53+
54+
static class DecimalHolder4917 {
55+
@JsonValue
56+
BigDecimal value;
57+
58+
private DecimalHolder4917(BigDecimal value) {
59+
this.value = value;
60+
}
61+
62+
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
63+
static DecimalHolder4917 of(BigDecimal value) {
64+
return new DecimalHolder4917(value);
65+
}
66+
}
67+
4468
/*
4569
/**********************************************************
4670
/* Test methods
@@ -204,4 +228,20 @@ public void testBigDecimalWithBuffering() throws Exception
204228
NestedBigDecimalHolder2784.class);
205229
assertEquals(VALUE, result.holder.value);
206230
}
231+
232+
// [databind#4917]
233+
@Test
234+
public void testIssue4917() throws Exception {
235+
final String bd = "100.00";
236+
final double d = 50.0;
237+
final DeserializationIssue4917 value = new DeserializationIssue4917();
238+
value.decimalHolder = DecimalHolder4917.of(new BigDecimal(bd));
239+
value.number = d;
240+
final byte[] data = MAPPER.writeValueAsBytes(value);
241+
242+
final DeserializationIssue4917 result = MAPPER.readValue(
243+
data, DeserializationIssue4917.class);
244+
assertEquals(value.decimalHolder.value, result.decimalHolder.value);
245+
assertEquals(value.number, result.number);
246+
}
207247
}

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/testutil/PrefixInputDecorator.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
import com.fasterxml.jackson.core.io.IOContext;
77
import com.fasterxml.jackson.core.io.InputDecorator;
8-
import org.junit.jupiter.api.Test;
9-
import static org.junit.jupiter.api.Assertions.*;
108

119
@SuppressWarnings("serial")
1210
public class PrefixInputDecorator extends InputDecorator

0 commit comments

Comments
 (0)