drzhonghao opened a new issue, #12251:
URL: https://github.com/apache/lucene/issues/12251
### Description
parseRepeatExp has the following code:
final RegExp parseRepeatExp() throws IllegalArgumentException {
..
if (start == pos) throw new IllegalArgumentException("integer expected at
position " + pos);
if (start != pos) m = Integer.parseInt(originalString.substring(start, pos));
...
}
Integer.parseInt(originalString.substring(start, pos)) can throw
NumberFormatException, but not IllegalArgumentException. Please note that the
above statement throws IllegalArgumentException.
Indeed, in the same class, another method rethrow IllegalArgumentException
as follows:
final RegExp parseSimpleExp() throws IllegalArgumentException {
...
try {
if (i == 0 || i == s.length() - 1 || i != s.lastIndexOf('-'))
throw new NumberFormatException();
String smin = s.substring(0, i);
String smax = s.substring(i + 1, s.length());
int imin = Integer.parseInt(smin);
int imax = Integer.parseInt(smax);
int digits;
if (smin.length() == smax.length()) digits = smin.length();
else digits = 0;
if (imin > imax) {
int t = imin;
imin = imax;
imax = t;
}
return makeInterval(flags, imin, imax, digits);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("interval syntax error at
position " + (pos - 1), e);
}
}
It can be better for parseRepeatExp to rethrow IllegalArgumentException. Can
this problem be fixed?
### Version and environment details
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]