Skip to content

Commit

Permalink
Make this exception lightweight, since it is only to unroll stack.
Browse files Browse the repository at this point in the history
This exception is immediately caught everywhere ConvertDouble is
used, triggering a proper Ruby exception. The creation of a stack
trace here is therefore extraneous.
headius committed Sep 29, 2015
1 parent 20acc1b commit e4727c3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/src/main/java/org/jruby/util/ConvertDouble.java
Original file line number Diff line number Diff line change
@@ -155,10 +155,20 @@ private double completeCalculation() {

return SafeDoubleParser.parseDouble(new String(chars, 0, charsIndex));
}

class LightweightNumberFormatException extends NumberFormatException {
public LightweightNumberFormatException(String message) {
super(message);
}
@Override
public Throwable fillInStackTrace() {
return this;
}
}

private boolean strictError() {
if (isStrict) {
throw new NumberFormatException("does not meet strict criteria");
throw new LightweightNumberFormatException("does not meet strict criteria");
} else {
return true; // means EOS for non-strict
}

0 comments on commit e4727c3

Please sign in to comment.