Skip to content

Commit e271058

Browse files
committed
fix: #674, should throw expception while reaching MAX_LOOP_COUNT
1 parent 900adca commit e271058

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

src/main/java/com/googlecode/aviator/code/asm/ASMCodeGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ public void onJoinLeft(final Token<?> lookahead) {
539539
visitLeftBranch(lookahead, IFNE, OperatorType.OR);
540540
}
541541

542-
private void visitLeftBranch(final Token<?> lookahead, final int ints, final OperatorType opType) {
542+
private void visitLeftBranch(final Token<?> lookahead, final int ints,
543+
final OperatorType opType) {
543544
this.checkExecutionTimeout();
544545
if (!OperationRuntime.hasRuntimeContext(this.compileEnv, opType)) {
545546
visitBoolean();

src/main/java/com/googlecode/aviator/parser/ExpressionParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,9 +1737,11 @@ private Token<?> value2token(final Object val) {
17371737
} else if (val == null) {
17381738
return Variable.NIL;
17391739
} else if (val instanceof String) {
1740-
return (new StringToken((String) val, this.lexer.getLineNo(), this.lookahead.getStartIndex()));
1740+
return (new StringToken((String) val, this.lexer.getLineNo(),
1741+
this.lookahead.getStartIndex()));
17411742
} else if (val instanceof Number) {
1742-
return (new NumberToken((Number) val, val.toString(), this.lexer.getLineNo(), this.lookahead.getStartIndex()));
1743+
return (new NumberToken((Number) val, val.toString(), this.lexer.getLineNo(),
1744+
this.lookahead.getStartIndex()));
17431745
} else if (val instanceof Boolean) {
17441746
return (((boolean) val) ? Variable.TRUE : Variable.FALSE);
17451747
} else {

src/main/java/com/googlecode/aviator/runtime/function/seq/SeqIncludeFunction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.Map;
1919
import java.util.Set;
20+
import com.googlecode.aviator.exception.ExpressionRuntimeException;
2021
import com.googlecode.aviator.runtime.RuntimeUtils;
2122
import com.googlecode.aviator.runtime.function.AbstractFunction;
2223
import com.googlecode.aviator.runtime.type.AviatorBoolean;
@@ -56,6 +57,8 @@ public AviatorObject call(final Map<String, Object> env, final AviatorObject arg
5657
break;
5758
}
5859
}
60+
} catch (ExpressionRuntimeException e) {
61+
throw e;
5962
} catch (Exception e) {
6063
RuntimeUtils.printStackTrace(env, e);
6164
return AviatorBoolean.FALSE;

src/test/java/com/googlecode/aviator/test/function/FunctionTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,4 +1607,10 @@ public String toString() {
16071607
return "User{" + "id=" + this.id + ", age=" + this.age + ", name='" + this.name + '\'' + '}';
16081608
}
16091609
}
1610+
1611+
@Test(expected = ExpressionRuntimeException.class)
1612+
public void testIssue674() {
1613+
this.instance.setOption(Options.MAX_LOOP_COUNT, 3);
1614+
this.instance.execute("include(seq.list(1,2,3,4),4)");
1615+
}
16101616
}

0 commit comments

Comments
 (0)