We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
不当的表达式可能会导致应用崩溃 代码
@Data class Alarm { String appName; String source; String alarmTime; Integer times; Integer alarmLevel; Map<String, Object> env = new HashMap<>(); }
@Test public void testLambda02() { Alarm alarm = new Alarm(); alarm.getEnv().put("requestPath", "/test"); alarm.getEnv().put("status", "404"); alarm.getEnv().put("appName", "rule-test"); alarm.getEnv().put("source", "nginx"); alarm.getEnv().put("times", 100); alarm.getEnv().put("alarmLevel", 1); // AviatorEvaluatorInstance 多实例 AviatorEvaluatorInstance instance = AviatorEvaluator.newInstance(); String expression = "(lambda (x) -> lambda(y) -> lambda(z) -> x + y + z end end end)(appName)"; System.out.println(instance.execute(expression, alarm.getEnv(), true)); }
运算结果死循环
java.lang.StackOverflowError at com.googlecode.aviator.runtime.type.AviatorObject.toString(AviatorObject.java:39) at java.lang.String.valueOf(String.java:2994) at java.lang.StringBuilder.append(StringBuilder.java:131) at com.googlecode.aviator.runtime.type.AviatorObject.desc(AviatorObject.java:73) at com.googlecode.aviator.runtime.type.AviatorObject.toString(AviatorObject.java:39) at java.lang.String.valueOf(String.java:2994) at java.lang.StringBuilder.append(StringBuilder.java:131) at com.googlecode.aviator.runtime.type.AviatorObject.desc(AviatorObject.java:73) at com.googlecode.aviator.runtime.type.AviatorObject.toString(AviatorObject.java:39) at java.lang.String.valueOf(String.java:2994)
The text was updated successfully, but these errors were encountered:
比较怪,我调查下
Sorry, something went wrong.
这个其实不是表达式的问题,而是因为 AviatorObject#toString 在遇到是函数的情况下递归(desc 和 toString 递归调用)了,会修复下。
遇到返回值是 lambda 的情况,不调用 toString 是不会遇到这个问题的。这里 System.out.println 默认调用了 toString 方法。改成类似:
Object s = (instance.execute(expression, env, true));
就不会报错了。
(fix) Stackoverflow when calling AviatorFunction#toString, #184
104505b
c5d77f3
发布了 4.2.9(可能要等一天等 maven central 同步) https://github.com/killme2008/aviator/releases/tag/aviator-4.2.9
killme2008
No branches or pull requests
不当的表达式可能会导致应用崩溃
代码
运算结果死循环
The text was updated successfully, but these errors were encountered: