Skip to content

JsonObjectReader can get stuck when deserializer throws #5278

@ossianwinter

Description

@ossianwinter

Integration

sentry

Java Version

21

Other Error Monitoring Solution

No

Other Error Monitoring Solution Name

No response

Version

8.38.0

Steps to Reproduce

JsonReader.nextName can throw exceptions, I think this causes nextMapOrNull to spin forever, since the token isn't consumed. While I'm not sure what caused the "bad" input this all seems to start in SentryEnvelopeItem.getLogs.

I'll be using nextMapOrNull (that's what we encountered this issue for) but this probably happens for arrays as well.

What is presumably the same path can be reproduced with this snipet:

final var reader = new JsonObjectReader(new StringReader("{\"x\": {}}"));
reader.nextMapOrNull(NoOpLogger.getInstance(), (_, _) -> {
  throw new IllegalStateException();
});

Expected Result

nextMapOrNull should, at some point, return.

Actual Result

nextMapOrNull never returns, instead it spins forever.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions