Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public BigDecimal getDecimalValue() throws IOException {
NumberValue number = ref.asNumber();
//optimization to not convert the value to BigInteger unnecessarily
if (number.isValidByte() || number.isValidShort() || number.isValidInt() || number.isValidLong()) {
return BigDecimal.valueOf(number.asInt());
return BigDecimal.valueOf(number.asLong());
}
else {
return new BigDecimal(number.asBigInteger());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -373,4 +374,16 @@ public void testDisableFeatureAutoCloseSource() throws IOException {
objectMapper.readValue(in, new TypeReference<List<Integer>>() {});
objectMapper.readValue(in, new TypeReference<List<Integer>>() {});
}

@Test
public void testParseBigDecimal() throws IOException {
ArrayList<BigDecimal> list = new ArrayList<BigDecimal>();
list.add(new BigDecimal(Long.MAX_VALUE));
ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
byte[] bytes = objectMapper.writeValueAsBytes(list);

ArrayList<BigDecimal> result = objectMapper.readValue(
bytes, new TypeReference<ArrayList<BigDecimal>>() {});
assertEquals(list, result);
}
}