RFE: Make MAX_ERROR_TOKEN_LENGTH configurable

36 views
Skip to first unread message

Gili

unread,
Jun 5, 2023, 6:24:37 PM6/5/23
to jackson-user
Hi,

When Jackson throws an exception, it quotes the JSON that triggered the exception. Unfortunately, after MAX_ERROR_TOKEN_LENGTH bytes it truncates the message so if a section of interest is further down it becomes very hard to debug.

Is it possible to make this limit configurable?

Thank you,
Gili

Tatu Saloranta

unread,
Jun 5, 2023, 6:30:24 PM6/5/23
to jackso...@googlegroups.com
There is no way to configure this currently.

If anyone has time and interest in making this configurable I'd be
happy to help; it'd need to go via `JsonFactory.builder()`
configuration. But static config methods (static method, system
properties) not acceptable.

Ideally there would probably an extensible set (similar to new
StreamReadConstraints setting, but different) to modify so it'd be
easier to add/configure different settings.

-+ Tatu +-
> --
> You received this message because you are subscribed to the Google Groups "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/9eca88c0-53dd-421e-b931-c8580c69be63n%40googlegroups.com.

Gili Tzabari

unread,
Jun 6, 2023, 9:03:41 AM6/6/23
to jackso...@googlegroups.com

For what it's worth, I worked around the problem this way:

Throwable throwable = result.getThrowable();
if (throwable instanceof JsonProcessingException jpe)
{
  // Jackson truncates the JSON if it's too long. Let's log the full content.
  Object rawContent = jpe.getLocation().contentReference().getRawContent();
  log.error(rawContent.toString());
}

It's still ugly in the sense that there is no way to disable the original exception, so I get a truncated exception message first followed by this log.

Gili

Tatu Saloranta

unread,
Jun 6, 2023, 2:53:08 PM6/6/23
to jackso...@googlegroups.com
Thank you sharing this, it makes sense (wrt newly added functionality
in location, content source).

-+ Tatu +-
> To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/aaadd7bf-718c-0cc4-0619-9116912b3103%40gmail.com.

Joo Hyuk Kim (김주혁)

unread,
Jun 10, 2023, 10:04:53 AM6/10/23
to jackson-user
I will try to implement the configuration. If that's okay? 🙏🏼

Tatu Saloranta

unread,
Jun 10, 2023, 7:48:25 PM6/10/23
to jackso...@googlegroups.com
On Sat, Jun 10, 2023 at 7:04 AM Joo Hyuk Kim (김주혁) <bean...@gmail.com> wrote:
>
> I will try to implement the configuration. If that's okay? 🙏🏼

Absolutely!

-+ Tatu +-
> To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/5872dc12-53bb-4d52-bd65-48cbface65efn%40googlegroups.com.

Joo Hyuk Kim (김주혁)

unread,
Jun 11, 2023, 1:17:20 AM6/11/23
to jackson-user

Joo Hyuk Kim (김주혁)

unread,
Aug 3, 2023, 7:11:03 AM8/3/23
to jackson-user
This has been resolved by https://github.com/FasterXML/jackson-core/issues/1066, in Jackson 2.16.
Reply all
Reply to author
Forward
0 new messages