@@ -76,6 +76,24 @@ static class NestedBigDecimalHolder2784 {
76
76
public BigDecimalHolder2784 holder ;
77
77
}
78
78
79
+ static class DeserializationIssue4917 {
80
+ public DecimalHolder4917 decimalHolder ;
81
+ public Double number ;
82
+ }
83
+
84
+ static class DecimalHolder4917 {
85
+ public BigDecimal value ;
86
+
87
+ public DecimalHolder4917 (BigDecimal value ) {
88
+ this .value = value ;
89
+ }
90
+
91
+ @ JsonCreator
92
+ static DecimalHolder4917 of (BigDecimal value ) {
93
+ return new DecimalHolder4917 (value );
94
+ }
95
+ }
96
+
79
97
/*
80
98
/**********************************************************************
81
99
/* Helper classes, serializers/deserializers/resolvers
@@ -362,4 +380,39 @@ public void testBigDecimalUnwrapped() throws Exception
362
380
NestedBigDecimalHolder2784 result = mapper .readValue (JSON , NestedBigDecimalHolder2784 .class );
363
381
assertEquals (new BigDecimal ("5.00" ), result .holder .value );
364
382
}
383
+
384
+ private final String BIG_DEC_STR ;
385
+ {
386
+ StringBuilder sb = new StringBuilder ("-1234." );
387
+ // Above 500 chars we get a problem:
388
+ for (int i = 520 ; --i >= 0 ; ) {
389
+ sb .append ('0' );
390
+ }
391
+ BIG_DEC_STR = sb .toString ();
392
+ }
393
+ private final BigDecimal BIG_DEC = new BigDecimal (BIG_DEC_STR );
394
+
395
+ // [databind#4694]: decoded wrong by jackson-core/FDP for over 500 char numbers
396
+ @ Test
397
+ public void bigDecimal4694FromString () throws Exception
398
+ {
399
+ assertEquals (BIG_DEC , MAPPER .readValue (BIG_DEC_STR , BigDecimal .class ));
400
+ }
401
+
402
+ @ Test
403
+ public void bigDecimal4694FromBytes () throws Exception
404
+ {
405
+ byte [] b = utf8Bytes (BIG_DEC_STR );
406
+ assertEquals (BIG_DEC , MAPPER .readValue (b , 0 , b .length , BigDecimal .class ));
407
+ }
408
+
409
+ @ Test
410
+ public void bigDecimal4917 () throws Exception
411
+ {
412
+ DeserializationIssue4917 issue = MAPPER .readValue (
413
+ a2q ("{'decimalHolder':100.00,'number':50}" ),
414
+ DeserializationIssue4917 .class );
415
+ assertEquals (new BigDecimal ("100.00" ), issue .decimalHolder .value );
416
+ }
417
+
365
418
}
0 commit comments