Project

General

Profile

Bug #10221

jackson has a limitation of 20million for a string value

Added by Constantin Asofiei about 1 year ago. Updated about 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:

History

#2 Updated by Constantin Asofiei about 1 year ago

Jackson has a limitation of 20 million length for string values in a JSON - see https://lists.apache.org/thread/pfbxr4o1p7h3r97bv2xchnfpv8c9q6dw

The problem was exposed when FWD was producing a wrong JSON file.

The solution is to change the defaults, something like this:
package com.goldencode.p2j.oo.json;

public class JsonBackend
{
   private JsonBackend()
   {
      StreamReadConstraints.overrideDefaultStreamReadConstraints(
      new StreamReadConstraints(StreamReadConstraints.DEFAULT_MAX_NUM_LEN, 
                                StreamReadConstraints.DEFAULT_MAX_DOC_LEN,
                                StreamReadConstraints.DEFAULT_MAX_DEPTH, 
                                100_000_000, // 100MB 
                                StreamReadConstraints.DEFAULT_MAX_NAME_LEN)
      {

      });

      factory = new JsonFactory().configure(Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);
   }
  • this needs to be JVM-wide and at FWD server startup, so JsonBackend may not be the best place
  • do we make this configurable?
  • we need to ensure if FWD fails because of this, a real exception is show in the server log

As a side note, after the root cause was fixed, even the 'good json' required a ~12 million length string.

#3 Updated by Greg Shah about 1 year ago

Is there any downside to making this change? (e.g. increased memory usage by default)

do we make this configurable?

Yes

#4 Updated by Constantin Asofiei about 1 year ago

Greg Shah wrote:

Is there any downside to making this change? (e.g. increased memory usage by default)

Not really, except the memory usage, but this is used only if the json requires it. jackson I think added this limit as the json text can be abused and thus crashing the JVM entirely.

Also available in: Atom PDF