Skip to content

YassonParser.isIntegralNumber throws a JsonbException instead of IllegalStateException (as stipulated on the spec). #707

Description

@TheEliteGentleman

The JsonParser.isIntegralNumber() spec states that:

 @throws IllegalStateException - when the parser state is not VALUE_NUMBER

Unfortunately, when running calling that method on a container that uses Yasson, it throws the JsonbException instead;

Here's the stacktrace:

jakarta.json.bind.JsonbException: Value type STRING at key id is not a JsonNumber.
        at org.eclipse.yasson.internal.jsonstructure.JsonObjectIterator.createIncompatibleValueError(JsonObjectIterator.java:130)
        at org.eclipse.yasson.internal.jsonstructure.JsonStructureToParserAdapter.getJsonNumberValue(JsonStructureToParserAdapter.java:122)
        at org.eclipse.yasson.internal.jsonstructure.JsonStructureToParserAdapter.isIntegralNumber(JsonStructureToParserAdapter.java:88)
        at org.eclipse.yasson.internal.deserializer.YassonParser.isIntegralNumber(YassonParser.java:96)

This breaks the code that we've implemented when implementing and running the custom JsonbDeserializer.deserialize() method:

RequestId id = null;
try {
	if (parser.isIntegralNumber()) {
		id = RequestId.of(parser.getLong());
	}
} catch (IllegalStateException e) {
	id = RequestId.of(parser.getString());
}

System information:

  • OS: Windows 10
  • Java Version: 26
  • Yasson Version: 3.0.3
  • Jakarta EE container: Eclipse GlassFish Embedded 9.0.0-M1

Note: This is not an issue on Parsson.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working right

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions