-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Milestone
Description
This is the smallest example I could get to reproduce the issue:
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
class Test {
public static void main(String[] args) throws Exception {
double[] data = new double[4096];
for (int i = 0; i < data.length; ++i) {
data[i] = (double) i;
}
ObjectMapper mapper = new ObjectMapper(new SmileFactory());
byte[] encoded = mapper.writeValueAsBytes(data);
double[] decoded1 = mapper.readValue(encoded, double[].class);
System.out.println(decoded1.length);
InputStream input = new ByteArrayInputStream(encoded);
double[] decoded2 = mapper.readValue(input, double[].class); // This fails on 2.4.0
System.out.println(decoded2.length);
}
}
Output with 2.2.0, 2.4.0-rc3, and 2.4.0. Note I only see the issue on 2.4.0 the rc3 version works fine.
$ ./test.sh 2.2.0
4096
4096
$ ./test.sh 2.4.0-rc3
4096
4096
$ ./test.sh 2.4.0
4096
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 8000
at com.fasterxml.jackson.dataformat.smile.SmileParser._fourBytesToIntSlow(SmileParser.java:2063)
at com.fasterxml.jackson.dataformat.smile.SmileParser._fourBytesToInt(SmileParser.java:2051)
at com.fasterxml.jackson.dataformat.smile.SmileParser._finishDouble(SmileParser.java:2101)
at com.fasterxml.jackson.dataformat.smile.SmileParser._finishNumberToken(SmileParser.java:1902)
at com.fasterxml.jackson.dataformat.smile.SmileParser._parseNumericValue(SmileParser.java:1837)
at com.fasterxml.jackson.core.base.ParserBase.getDoubleValue(ParserBase.java:662)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDoublePrimitive(StdDeserializer.java:669)
at com.fasterxml.jackson.databind.deser.std.PrimitiveArrayDeserializers$DoubleDeser.deserialize(PrimitiveArrayDeserializers.java:488)
at com.fasterxml.jackson.databind.deser.std.PrimitiveArrayDeserializers$DoubleDeser.deserialize(PrimitiveArrayDeserializers.java:468)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3051)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2192)
at Test.main(Test.java:21)
Metadata
Metadata
Assignees
Labels
No labels