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;