File tree Expand file tree Collapse file tree
main/java/org/msgpack/jackson/dataformat
test/java/org/msgpack/jackson/dataformat Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -287,7 +287,7 @@ public BigDecimal getDecimalValue() throws IOException {
287287 NumberValue number = ref .asNumber ();
288288 //optimization to not convert the value to BigInteger unnecessarily
289289 if (number .isValidByte () || number .isValidShort () || number .isValidInt () || number .isValidLong ()) {
290- return BigDecimal .valueOf (number .asInt ());
290+ return BigDecimal .valueOf (number .asLong ());
291291 }
292292 else {
293293 return new BigDecimal (number .asBigInteger ());
Original file line number Diff line number Diff line change 1414import java .math .BigDecimal ;
1515import java .math .BigInteger ;
1616import java .nio .ByteBuffer ;
17+ import java .util .ArrayList ;
1718import java .util .Arrays ;
1819import java .util .List ;
1920import java .util .Map ;
@@ -373,4 +374,16 @@ public void testDisableFeatureAutoCloseSource() throws IOException {
373374 objectMapper .readValue (in , new TypeReference <List <Integer >>() {});
374375 objectMapper .readValue (in , new TypeReference <List <Integer >>() {});
375376 }
377+
378+ @ Test
379+ public void testParseBigDecimal () throws IOException {
380+ ArrayList <BigDecimal > list = new ArrayList <BigDecimal >();
381+ list .add (new BigDecimal (Long .MAX_VALUE ));
382+ ObjectMapper objectMapper = new ObjectMapper (new MessagePackFactory ());
383+ byte [] bytes = objectMapper .writeValueAsBytes (list );
384+
385+ ArrayList <BigDecimal > result = objectMapper .readValue (
386+ bytes , new TypeReference <ArrayList <BigDecimal >>() {});
387+ assertEquals (list , result );
388+ }
376389}
You can’t perform that action at this time.
0 commit comments