From 953a643846ad42c7ff8649e39b6865b8fcf9ad9b Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 6 Dec 2023 10:04:27 +0100 Subject: [PATCH 1/2] update javadoc to highlight that this class is for internal jackson use --- .../fasterxml/jackson/core/io/BigDecimalParser.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/core/io/BigDecimalParser.java b/src/main/java/com/fasterxml/jackson/core/io/BigDecimalParser.java index 0e42d163e2..a2f5687ef3 100644 --- a/src/main/java/com/fasterxml/jackson/core/io/BigDecimalParser.java +++ b/src/main/java/com/fasterxml/jackson/core/io/BigDecimalParser.java @@ -12,12 +12,20 @@ // https://github.com/eobermuhlner/big-math/commit/7a5419aac8b2adba2aa700ccf00197f97b2ad89f /** - * Helper class used to implement more optimized parsing of {@link BigDecimal} for REALLY - * big values (over 500 characters) + * Internal Jackson Helper class used to implement more optimized parsing of {@link BigDecimal} for REALLY + * big values (over 500 characters). + *

+ * This class is not meant to be used directly. It is designed to be used by Jackson JSON parsers (and parsers + * for other Jackson supported data formats). The parsers check for invalid characters and the length of the number. + * Without these checks, this parser is susceptible to performing badly with invalid inputs. If you need to parse + * numbers directly, please use JavaBigDecimalParser in fastdoubleparser + * instead. + *

*

* Based on ideas from this * this * git commit. + *

* * @since 2.13 */ From 46f706beb744fd7c927741e0acf36ec61e5a7399 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 6 Dec 2023 10:08:12 +0100 Subject: [PATCH 2/2] Update BigDecimalParser.java --- .../jackson/core/io/BigDecimalParser.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/com/fasterxml/jackson/core/io/BigDecimalParser.java b/src/main/java/com/fasterxml/jackson/core/io/BigDecimalParser.java index a2f5687ef3..921fca70e5 100644 --- a/src/main/java/com/fasterxml/jackson/core/io/BigDecimalParser.java +++ b/src/main/java/com/fasterxml/jackson/core/io/BigDecimalParser.java @@ -35,10 +35,23 @@ public final class BigDecimalParser private BigDecimalParser() {} + /** + * Internal Jackson method. Please do not use. + * + * @param valueStr + * @return BigDecimal value + * @throws NumberFormatException + */ public static BigDecimal parse(String valueStr) { return parse(valueStr.toCharArray()); } + /** + * Internal Jackson method. Please do not use. + * + * @return BigDecimal value + * @throws NumberFormatException + */ public static BigDecimal parse(final char[] chars, final int off, final int len) { try { if (len < 500) { @@ -66,6 +79,13 @@ public static BigDecimal parse(final char[] chars, final int off, final int len) } } + /** + * Internal Jackson method. Please do not use. + * + * @param chars + * @return BigDecimal value + * @throws NumberFormatException + */ public static BigDecimal parse(char[] chars) { return parse(chars, 0, chars.length); }