Repository navigation
Skip serializing string nodes for const error arguments - #1393
Conversation
Review of #1393Reviewed at head I compared the old and new conversions with a probe on Jackson 3.0.1, 3.1.8 and 3.2.4, over 20 node types: string, empty string, int, long, short, float, double, BigInteger, BigDecimal, boolean, null, binary, POJO, object, array and missing. They matched every time. MinorNumbers, booleans and null still pay for The shortcut only applies when the class is exactly Suggested change: private static String asString(JsonNode node) {
return node.asStringOpt().orElseGet(node::toString);
}This builds the default only when it is used. In the same probe it gave the same string as the old |
|
Thank you. I applied your suggestion.
The output is the same on 1.17M random inputs. |
Re-review of #1393Reviewed at head
|
Each failed
constcallsnode.toString()for the error arguments, also for a string node. This change usesasString()for aStringNode. The arguments are the same.const, no matchitems, 10 mixed valuesoneOf, 100 items, invalidoneOf, 100 items, validconstThe errors are the same on 1.1M inputs. Tests pass on JDK 17, 21 and 26.