Closed gianluca-valentini closed 10 months ago
Where is this exception thrown? Can you please report the exception stack trace and a code snippet to reproduce it?
Hi @rashtao Here the complete trace.
com.arangodb.ArangoDBException: com.fasterxml.jackson.databind.JsonMappingException: String length (20049662) exceeds the maximum length (20000000) (through reference chain: com.arangodb.entity.BaseDocument["details"])
at com.arangodb.internal.serde.InternalSerdeImpl.deserialize(InternalSerdeImpl.java:168) ~[core-7.1.0.jar:7.1.0]
at com.arangodb.internal.serde.InternalSerdeImpl.deserialize(InternalSerdeImpl.java:60) ~[core-7.1.0.jar:7.1.0]
at com.arangodb.internal.serde.InternalSerdeImpl.deserializeUserData(InternalSerdeImpl.java:125) ~[core-7.1.0.jar:7.1.0]
at com.arangodb.internal.InternalArangoCollection.lambda$getDocumentResponseDeserializer$1(InternalArangoCollection.java:174) ~[core-7.1.0.jar:7.1.0]
at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:62) ~[core-7.1.0.jar:7.1.0]
at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:52) ~[core-7.1.0.jar:7.1.0]
at com.arangodb.internal.ArangoCollectionImpl.getDocument(ArangoCollectionImpl.java:134) ~[core-7.1.0.jar:7.1.0]
at com.arangodb.internal.ArangoCollectionImpl.getDocument(ArangoCollectionImpl.java:127) ~[core-7.1.0.jar:7.1.0]
at tech.sharelock.arango.client.dao.GenericDAO.saveVertex(GenericDAO.java:298) ~[client-arango-6.1.0-SNAPSHOT.jar:?]
at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: com.fasterxml.jackson.databind.JsonMappingException: String length (20049662) exceeds the maximum length (20000000) (through reference chain: com.arangodb.entity.BaseDocument["details"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:402) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:361) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1853) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1683) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:320) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2105) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1583) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.arangodb.internal.serde.InternalSerdeImpl.deserialize(InternalSerdeImpl.java:166) ~[core-7.1.0.jar:7.1.0]
... 15 more
Caused by: com.fasterxml.jackson.core.exc.StreamConstraintsException: String length (20049662) exceeds the maximum length (20000000)
at com.fasterxml.jackson.core.StreamReadConstraints.validateStringLength(StreamReadConstraints.java:295) ~[jackson-core-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.core.util.ReadConstrainedTextBuffer.validateStringLength(ReadConstrainedTextBuffer.java:27) ~[jackson-core-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.core.util.TextBuffer.finishCurrentSegment(TextBuffer.java:939) ~[jackson-core-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishString2(UTF8StreamJsonParser.java:2584) ~[jackson-core-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishAndReturnString(UTF8StreamJsonParser.java:2560) ~[jackson-core-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.getText(UTF8StreamJsonParser.java:335) ~[jackson-core-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializerNR._deserializeNR(UntypedObjectDeserializerNR.java:246) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializerNR.deserialize(UntypedObjectDeserializerNR.java:70) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.SettableAnyProperty.deserialize(SettableAnyProperty.java:198) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.SettableAnyProperty.deserializeAndSet(SettableAnyProperty.java:179) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1681) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:320) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2105) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1583) ~[jackson-databind-2.15.1.jar:2.15.1]
at com.arangodb.internal.serde.InternalSerdeImpl.deserialize(InternalSerdeImpl.java:166) ~[core-7.1.0.jar:7.1.0]
... 15 more
Consider that tech.sharelock.arango.client.dao.GenericDAO.saveVertex(GenericDAO.java:298) is my code where I save a Document that contains in 'details' attribute. The field 'details' contains a string text very large text.
That code is below
297: DocumentCreateEntity<Void> created = collection.insertDocument(document);
298: document = collection.getDocument(created.getKey(), BaseDocument.class);
Thanks Gianluca
Thanks for clarifying, this exception is not related to jackson-dataformat-velocypack
, but coming from Jackson com.fasterxml.jackson.databind.ObjectReader
, which is used in the ArangoDB Java driver InternalSerdeImpl
to deserialize JSON content type.
While this will be fixed in a future version of the driver, you can in the meantime work around it with either:
.protocol(Protocol.HTTP2_VPACK)
StreamReadConstraints.overrideDefaultStreamReadConstraints(
StreamReadConstraints
.builder()
.maxStringLength(Integer.MAX_VALUE) // your limit here
.build()
);
Note that (2) is potentially unsafe, because it will affect all Jackson instances in your application, i.e. also used for decoding web requests.
Hi @rashtao this is my code hat I use to create ArangoDB
ArangoDB arangoDB = new ArangoDB.Builder().host(host, port).user(_DB_USERID).password(_DB_PASSWORD) .useSsl(false).maxConnections(MAX_POOL_SIZE).connectionTtl(null) .timeout(0) .protocol(Protocol.HTTP2_JSON).build()
So you suggest to change Protocol.HTTP2_JSON
with Protocol.HTTP2_VPACK
. Do I have to change somthing else? The server installation require other changes or the workaround is just for java driver code?
after that i will add
StreamReadConstraints.overrideDefaultStreamReadConstraints(
StreamReadConstraints
.builder()
.maxStringLength(MY_LIMIT)
.build()
);
is that correct?
Thanks Gianluca
@rashtao I don't find the method overrideDefaultStreamReadConstraints for StreamReadConstraints class neither arango nor jackson package. Can you tell me where i'm wrong? Gianluca
com.fasterxml.jackson.core.StreamReadConstraints#overrideDefaultStreamReadConstraints(StreamReadConstraints)
, since Jackson 2.15.2
Thanks @rashtao I will migrate from 2.15.1 to 2.15.3. what's about the driver question?
You can change .protocol(Protocol.HTTP2_JSON)
with .protocol(Protocol.HTTP2_VPACK)
.
Note that you do not need to do both, either switching to VPACK or invoking overrideDefaultStreamReadConstraints
would be enough.
Thanks it works fine
Gianluca
Hi, i'm using v4.10 version of jackson dataformat velocypack. In ArangoDB i need sometimes to save some text and i have the follow error:
com.fasterxml.jackson.databind.JsonMappingException: String length (20049662) exceeds the maximum length (20000000).
How I can solve it? I know that jackson can increase the maximum length of textual values by using the setMaxTextLength method of the StreamReadConstraints class but I don't have access to it (or ObjectMapper mapper = new ObjectMapper(); mapper.reader().with(StreamReadConstraints.builder().setMaxTextLength(30000000).build())).
Is there something that I can use or set ot increase that value? Thanks Gianluca Valentini