Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading