From d7ed05230abb783d408fb884e90be3e472ad3afb Mon Sep 17 00:00:00 2001 From: Sagar Upadhyaya Date: Fri, 3 Oct 2025 12:14:47 -0700 Subject: [PATCH 1/3] Static string for parse error; remove commented code in ArrayUtils --- .../src/java/org/apache/lucene/util/ArrayUtil.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java b/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java index 2fee4e52b8b3..2c4bba068ca5 100644 --- a/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java +++ b/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java @@ -27,6 +27,8 @@ */ public final class ArrayUtil { + private static final String PARSING_EXCEPTION_MESSAGE = "Unable to parse"; + /** Maximum length for an array (Integer.MAX_VALUE - RamUsageEstimator.NUM_BYTES_ARRAY_HEADER). */ public static final int MAX_ARRAY_LENGTH = Integer.MAX_VALUE - RamUsageEstimator.NUM_BYTES_ARRAY_HEADER; @@ -90,24 +92,21 @@ private static int parse(char[] chars, int offset, int len, int radix, boolean n for (int i = 0; i < len; i++) { int digit = Character.digit(chars[i + offset], radix); if (digit == -1) { - throw new NumberFormatException("Unable to parse"); + throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); } if (max > result) { - throw new NumberFormatException("Unable to parse"); + throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); } int next = result * radix - digit; if (next > result) { - throw new NumberFormatException("Unable to parse"); + throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); } result = next; } - /*while (offset < len) { - - }*/ if (!negative) { result = -result; if (result < 0) { - throw new NumberFormatException("Unable to parse"); + throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); } } return result; From 2b71461b35a598af628c589eda5f829d8b34a823 Mon Sep 17 00:00:00 2001 From: Sagar Upadhyaya Date: Fri, 3 Oct 2025 12:15:42 -0700 Subject: [PATCH 2/3] Revert "Static string for parse error; remove commented code in ArrayUtils" This reverts commit d7ed05230abb783d408fb884e90be3e472ad3afb. --- .../src/java/org/apache/lucene/util/ArrayUtil.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java b/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java index 2c4bba068ca5..2fee4e52b8b3 100644 --- a/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java +++ b/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java @@ -27,8 +27,6 @@ */ public final class ArrayUtil { - private static final String PARSING_EXCEPTION_MESSAGE = "Unable to parse"; - /** Maximum length for an array (Integer.MAX_VALUE - RamUsageEstimator.NUM_BYTES_ARRAY_HEADER). */ public static final int MAX_ARRAY_LENGTH = Integer.MAX_VALUE - RamUsageEstimator.NUM_BYTES_ARRAY_HEADER; @@ -92,21 +90,24 @@ private static int parse(char[] chars, int offset, int len, int radix, boolean n for (int i = 0; i < len; i++) { int digit = Character.digit(chars[i + offset], radix); if (digit == -1) { - throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); + throw new NumberFormatException("Unable to parse"); } if (max > result) { - throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); + throw new NumberFormatException("Unable to parse"); } int next = result * radix - digit; if (next > result) { - throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); + throw new NumberFormatException("Unable to parse"); } result = next; } + /*while (offset < len) { + + }*/ if (!negative) { result = -result; if (result < 0) { - throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); + throw new NumberFormatException("Unable to parse"); } } return result; From 33de1041cf275172fe3080b6b31d18cbbecbe4aa Mon Sep 17 00:00:00 2001 From: Sagar Upadhyaya Date: Fri, 3 Oct 2025 12:14:47 -0700 Subject: [PATCH 3/3] Static string for parse error; remove commented code in ArrayUtils --- .../src/java/org/apache/lucene/util/ArrayUtil.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java b/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java index 2fee4e52b8b3..2c4bba068ca5 100644 --- a/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java +++ b/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java @@ -27,6 +27,8 @@ */ public final class ArrayUtil { + private static final String PARSING_EXCEPTION_MESSAGE = "Unable to parse"; + /** Maximum length for an array (Integer.MAX_VALUE - RamUsageEstimator.NUM_BYTES_ARRAY_HEADER). */ public static final int MAX_ARRAY_LENGTH = Integer.MAX_VALUE - RamUsageEstimator.NUM_BYTES_ARRAY_HEADER; @@ -90,24 +92,21 @@ private static int parse(char[] chars, int offset, int len, int radix, boolean n for (int i = 0; i < len; i++) { int digit = Character.digit(chars[i + offset], radix); if (digit == -1) { - throw new NumberFormatException("Unable to parse"); + throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); } if (max > result) { - throw new NumberFormatException("Unable to parse"); + throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); } int next = result * radix - digit; if (next > result) { - throw new NumberFormatException("Unable to parse"); + throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); } result = next; } - /*while (offset < len) { - - }*/ if (!negative) { result = -result; if (result < 0) { - throw new NumberFormatException("Unable to parse"); + throw new NumberFormatException(PARSING_EXCEPTION_MESSAGE); } } return result;