Skip to content

Commit 0376544

Browse files
committed
AVRO-1869: Java: Fix Decimal conversion from ByteBuffer.
1 parent 89a31b9 commit 0376544

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Trunk (not yet released)
1515
AVRO-1741: Python3: Fix error when codec is not in the header.
1616
(Matthew Hayes via blue)
1717

18+
AVRO-1869: Java: Fix Decimal conversion from ByteBuffer. (blue)
19+
1820
Avro 1.8.1 (14 May 2016)
1921

2022
INCOMPATIBLE CHANGES

lang/java/avro/src/main/java/org/apache/avro/Conversions.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public String getLogicalTypeName() {
8080
public BigDecimal fromBytes(ByteBuffer value, Schema schema, LogicalType type) {
8181
int scale = ((LogicalTypes.Decimal) type).getScale();
8282
// always copy the bytes out because BigInteger has no offset/length ctor
83-
byte[] bytes = value.get(new byte[value.remaining()]).array();
83+
byte[] bytes = new byte[value.remaining()];
84+
value.get(bytes);
8485
return new BigDecimal(new BigInteger(bytes), scale);
8586
}
8687

0 commit comments

Comments
 (0)