You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The JavaDoc for JsonGenerator.writeString(Reader, len) states that passing a len < 0 will write all contents of the reader. It throws an IndexOutOfBoundsException when the buffer in UTF8JsonGenerator becomes full but is not correctly flushed because the check for a full buffer does not take into account the negative len parameter.
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Index 8000 out of bounds for length 8000 (through reference chain: java.util.ArrayList[2]) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365) at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:338) at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:123) at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79) at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319) at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3905) at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:3176) at jackson.bug.JacksonBugTest.main(JacksonBugTest.java:36) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131) Suppressed: java.lang.IndexOutOfBoundsException: Range [0, 0 + 8001) out of bounds for length 8000 at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromIndexSize(Preconditions.java:82) at java.base/jdk.internal.util.Preconditions.checkFromIndexSize(Preconditions.java:343) at java.base/java.util.Objects.checkFromIndexSize(Objects.java:425) at java.base/java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:129) at com.fasterxml.jackson.core.json.UTF8JsonGenerator._flushBuffer(UTF8JsonGenerator.java:2085) at com.fasterxml.jackson.core.json.UTF8JsonGenerator.close(UTF8JsonGenerator.java:1127) at com.fasterxml.jackson.databind.util.ClassUtil.closeOnFailAndThrowAsIOE(ClassUtil.java:488) at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3907) ... 7 more Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 8000 out of bounds for length 8000 at com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeString(UTF8JsonGenerator.java:503) at jackson.bug.JacksonBugTest$ThingSerializer.serialize(JacksonBugTest.java:45) at jackson.bug.JacksonBugTest$ThingSerializer.serialize(JacksonBugTest.java:40) at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119) ... 12 more
The text was updated successfully, but these errors were encountered:
I encountered this using Jackson 2.9.9
The JavaDoc for JsonGenerator.writeString(Reader, len) states that passing a len < 0 will write all contents of the reader. It throws an IndexOutOfBoundsException when the buffer in UTF8JsonGenerator becomes full but is not correctly flushed because the check for a full buffer does not take into account the negative len parameter.
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Index 8000 out of bounds for length 8000 (through reference chain: java.util.ArrayList[2]) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365) at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:338) at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:123) at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79) at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319) at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3905) at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:3176) at jackson.bug.JacksonBugTest.main(JacksonBugTest.java:36) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131) Suppressed: java.lang.IndexOutOfBoundsException: Range [0, 0 + 8001) out of bounds for length 8000 at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromIndexSize(Preconditions.java:82) at java.base/jdk.internal.util.Preconditions.checkFromIndexSize(Preconditions.java:343) at java.base/java.util.Objects.checkFromIndexSize(Objects.java:425) at java.base/java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:129) at com.fasterxml.jackson.core.json.UTF8JsonGenerator._flushBuffer(UTF8JsonGenerator.java:2085) at com.fasterxml.jackson.core.json.UTF8JsonGenerator.close(UTF8JsonGenerator.java:1127) at com.fasterxml.jackson.databind.util.ClassUtil.closeOnFailAndThrowAsIOE(ClassUtil.java:488) at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3907) ... 7 more Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 8000 out of bounds for length 8000 at com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeString(UTF8JsonGenerator.java:503) at jackson.bug.JacksonBugTest$ThingSerializer.serialize(JacksonBugTest.java:45) at jackson.bug.JacksonBugTest$ThingSerializer.serialize(JacksonBugTest.java:40) at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119) ... 12 more
The text was updated successfully, but these errors were encountered: