alibaba / qlexpress Goto Github PK
View Code? Open in Web Editor NEWQLExpress is a powerful, lightweight, dynamic language for the Java platform aimed at improving developers’ productivity in different business scenes.
License: Apache License 2.0
QLExpress is a powerful, lightweight, dynamic language for the Java platform aimed at improving developers’ productivity in different business scenes.
License: Apache License 2.0
方法
public boolean containsValues(String... values)
表达式
xxx.containsValues(v1,v2)
报错
java.lang.Exception: run QlExpress Exception at line n
rt,想要判断条件为空怎么写
希望规则脚本中允许添加注释,如常见的// , /***/
在用Qlexpress 表达式利用spring jpa 查询动态数据的时候,发现不能查询,感觉是repository没有注入的原因。
后面在网上找了篇文章 http://blog.csdn.net/express_wind/article/details/7468700 ,但是还是没有解决。
想问问如何解决这个问题
下面的测试用例执行会解析不了上下文的值
@test
public void testArithmetic_map() throws Exception {
ExpressRunner runner = new ExpressRunner(true, true);
runner.addMacro("计算平均成绩","(90天浏览时长 + 数学 + 英语)/3");
IExpressContext<String, Object> context =new DefaultContext<String, Object>();
context.put("90天浏览时长", 88);
context.put("数学", 99);
context.put("英语", 95);
System.out.println(runner.execute("计算平均成绩", context, null, true, false));
}
[90天浏览时长]这样的key读取会有问题,具体的错误逻辑应该在ExpressParse.class中的transferWord2ExpressNode,针对数字开头的key没有考虑上述的特殊情况。
不知道还能不能更新啦改项目,我这边自己打个分支先改造了把
现在支持try catch 异常处理吗
我想在绑定的java类中,注入StringRedisTemplate,但是无法注入
@component
public class BeanExample {
@Autowired
private StringRedisTemplate stringRedisTemplate;
public boolean redisTest(String key) {
stringRedisTemplate.opsForValue().set(key, "shfskfhoifhjls");
return stringRedisTemplate.hasKey(key);
}
},我想注入StringRedisTemplate,这样做可以吗
@Test
public void testFunction2() throws Exception {
ExpressRunner runner = new ExpressRunner();
String exp = "System.out.println(args[0]);";
String[] args = {"123","456"};
IExpressContext<String, Object> context = new DefaultContext<String, Object>();
((DefaultContext<String, Object>) context).put("args", args);
Object result = runner.execute(exp,context,null,false,false);
}
发现上面这段代码在实际运行时调用的方法是
public void java.io.PrintStream.println(java.lang.Object)
却不是
public void java.io.PrintStream.println(java.lang.String)
debug时发现findMethod的type是class [Ljava.lang.String;
请问这是一个bug还是开发时特意保留的特性?
附debug到com.ql.util.express.ExpressUtil#findMethod的debugger截图
我想在绑定的java类中,注入StringRedisTemplate,但是无法注入
JDK 1.8
QLExpress 3.2.2
Windows 10
当使用Builder模式的属性时, 系统无法正确读取属性值.
public class ELDemoEntity {
private String name;
private Long id;
public String getName() {
return name;
}
public ELDemoEntity setName(String name) {
this.name = name;
return this;
}
public Long getId() {
return id;
}
public ELDemoEntity setId(Long id) {
this.id = id;
return this;
}
}
@Test
public void test5() throws Exception {
ExpressRunner runner = new ExpressRunner(true,true);
String express = "if(demo.getId()==1)then{demo.id=2};return 0";
System.out.println(express);
IExpressContext<String,Object> expressContext = new DefaultContext<String,Object>();
ELDemoEntity entity = new ELDemoEntity();
entity.setId(1L).setName("zhangsan");
expressContext.put("demo", entity);
Object r = runner.execute(express,
expressContext, null, false, false);
System.out.println("r=" + r);
System.out.println(entity.getId());
}
java.lang.Exception: run QlExpress Exception at line 1 :
at com.ql.util.express.instruction.detail.InstructionOperator.execute(InstructionOperator.java:48)
at com.ql.util.express.InstructionSet.executeInnerOrigiInstruction(InstructionSet.java:217)
at com.ql.util.express.InstructionSet.excute(InstructionSet.java:183)
at com.ql.util.express.InstructionSetRunner.execute(InstructionSetRunner.java:59)
at com.ql.util.express.InstructionSetRunner.execute(InstructionSetRunner.java:46)
at com.ql.util.express.InstructionSetRunner.executeOuter(InstructionSetRunner.java:18)
at com.ql.util.express.ExpressRunner.execute(ExpressRunner.java:587)
at com.ql.util.express.ExpressRunner.execute(ExpressRunner.java:555)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
...
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
Caused by: java.lang.RuntimeException: 不能访问cn.loopcloud.ELDemoEntity@59d4cd39的property:id
at com.ql.util.express.ExpressUtil.setProperty(ExpressUtil.java:587)
at com.ql.util.express.instruction.opdata.OperateDataField.setObject(OperateDataField.java:108)
at com.ql.util.express.instruction.op.OperatorEvaluate.executeInner(OperatorEvaluate.java:37)
at com.ql.util.express.instruction.op.OperatorEvaluate.executeInner(OperatorEvaluate.java:18)
at com.ql.util.express.instruction.op.OperatorBase.execute(OperatorBase.java:67)
at com.ql.util.express.instruction.detail.InstructionOperator.execute(InstructionOperator.java:44)
... 30 more
Caused by: java.lang.NoSuchMethodException: Property 'id' has no setter method in class 'class cn.loopcloud.ELDemoEntity'
at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:2084)
at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1903)
at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:2010)
at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:896)
at com.ql.util.express.ExpressUtil.setProperty(ExpressUtil.java:584)
... 35 more
请问,能在脚本中进行异常捕获吗?当业务逻辑复杂时,需要在脚本中对出现的异常进行捕获,进而进行补偿操作,QLExpress是否支持这种功能?
请问,QLExpress不支持注释功能吗?
你好,规则执行报错:
程序错误,不满足语法规范,没有匹配到合适的语法,最大匹配致[0:0]
报这种错感觉很难排查规则哪里写的不对。
各位在排查这种问题的方法是什么,有没有工具支持呢
加了注释(//)报语法错误,去掉就OK了
是不支持还是我用法不正确?
目前的错误提示是这样的:java.lang.Exception: 程序错误,不满足语法规范,没有匹配到合适的语法,最大匹配致[0:2]
没有将分词结果暴露出来,具体错误提示在前端没法显示,不利于快速定位问题
ExpressRunner runner = new ExpressRunner(false, false);
runner.addFunctionOfServiceMethod("changeBrand",new BrandService(),"changeBrand",new Class[] {DroolsRequest.class},null);
runner.addMacro("changeBrandMacro","changeBrand11(droolsRequest)");
DefaultContext<String, Object> context = new DefaultContext<>();
context.put("PARAM1", 12);
context.put("PARAM2", 60);
context.put("droolsRequest",droolsRequest);
expression = initial(runner, “changeBrandMacro and PARAM1 + PARAM2>60”);
result = (Boolean) runner.execute(expression, context, errorInfo, true, false);
其中
public class BrandService {
public boolean changeBrand(DroolsRequest droolsRequest){
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println(droolsRequest.asXML());
return true;
}
}
报错
java.lang.Exception: 在Runner的操作符定义和自定义函数中都没有找到"changeBrand"的定义
我看了下源码,macro中去调用function时候,查找的function是去symbolTable找的,但是addFunctionOfServiceMethod却是往functions里边添加的,请问是我什么地方写错了么?
Just like spring el\ognl\jstl,alibba QLexpress alse allow programmer to directly call the Java Object to execute the method using the java reflection mechanism,
but there is no any security restrictions that rise a security risk while editing rules, just like that poc:
so,that cause a remote code execution;
Although it is a feature, there are security risks in design.
fix:
如题,对比了阿里云上面的早起代码,猜测是缺少这部分代码http://code.taobao.org/p/QLExpress/src/branches/3.0.3/src/main/resources/com/ql/util/express/console/
如题
想定义一个operator ,以实现“ 以 **** 打头”的效果,有什么好的方法吗
原文 “取绝对值(-100);转换为大写("hello world");打印("你好吗?");contains("helloworld","aeiou")”
前后双引号(“”)是中文的引号,contains单词前的分号(;)是中文的分号
QL表达式中是否支持Pattern正则匹配?
您好,大神:
最近在用贵公司的ql,可是发现if里面无法嵌套if语句,比如if(if 1==2 then false else true) then 1 else 2
这种语句无法执行,程序会报:程序错误,不满足语法规范。
请问一下支持类似这种语法吗?已加您微信了,不知道您收到,谢谢大神。
version : 3.2.0
for the following program:
runner.addOperatorWithAlias("如果", "if",null);
runner.addOperatorWithAlias("则", "then",null);
runner.addOperatorWithAlias("否则", "else",null);
exp = "如果 (如果 1==2 则 false 否则 true) 则 {2+2;} 否则 {20 + 20;}";
DefaultContext<String, Object> context = new DefaultContext<String, Object>();
runner.execute(exp,nil,null,false,false,null);
step by step debuging, found that the following function does parse not well
private static QLMatchResult findMatchStatementWithAddRoot(INodeTypeManager aManager,QLPatternNode pattern ,List<? extends IDataNode> nodes,int point,boolean isRoot,AtomicLong maxMatchPoint) throws Exception{
QLMatchResult result = null;
List<QLMatchResultTree> tempList = null;
int count = 0;
int lastPoint = point;
while(true){
QLMatchResult tempResult = null;
if (pattern.matchMode == MatchMode.DETAIL) {
tempResult = matchDetailOneTime(aManager,pattern,nodes, lastPoint,maxMatchPoint);
}else if (pattern.matchMode == MatchMode.AND) {
tempResult = matchAndOneTime(aManager,pattern,nodes, lastPoint,maxMatchPoint);
}else if (pattern.matchMode == MatchMode.OR) {
tempResult = matchOrOneTime(aManager,pattern,nodes, lastPoint,maxMatchPoint);
}else{
throw new Exception("不正确的类型:" + pattern.matchMode.toString());
}
if(tempResult == null){
if(count >= pattern.minMatchNum && count <=pattern.maxMatchNum){
//正确匹配
if(tempList == null){
tempList = new ArrayList<QLMatchResultTree>();
}
result = new QLMatchResult(tempList,lastPoint);
}else{
result = null;
}
break;
}else{
if(tempList == null){
tempList = new ArrayList<QLMatchResultTree>();
}
lastPoint = tempResult.matchLastIndex;
if(pattern.isTreeRoot == true){
if(tempResult.matchs.size() > 1){
throw new Exception("根节点的数量必须是1");
}
if(tempList.size() == 0){
tempList.addAll(tempResult.matchs);
}else{
tempResult.matchs.get(0).addLeftAll(tempList);
tempList = tempResult.matchs;
}
}else{
tempList.addAll(tempResult.matchs);
}
}
count = count + 1;
if(count == pattern.maxMatchNum){
result = new QLMatchResult(tempList,lastPoint);
break;
}
}
if(result != null && pattern.isSkip == true){
//忽略跳过所有匹配到的节点
result.matchs.clear();
}
if(result != null && result.matchs.size() >0 && pattern.rootNodeType != null){
QLMatchResultTree tempTree = new QLMatchResultTree(pattern.rootNodeType,nodes.get(0).createExpressNode(pattern.rootNodeType,null));
tempTree.addLeftAll(result.matchs);
result.matchs.clear();
result.matchs.add(tempTree);
}
return result;
}
例:
JSONObject json = new JSONObject();
json.put("attr", Lists.newArrayList("1", "2", "3"));
DefaultContext<String, Object> properties = new DefaultContext<String, Object>();
properties.put("json", json);
String ex = "json.attr.get(1)";
Object r = runner.execute(ex, properties, null, true, false);
System.out.println(r);
//是否可以支持下面的操作?
// ex = "json.attr[1]";
// r = runner.execute(ex, properties, null, true, false);
// System.out.println(r);
传入的[ - ]符号,输出会变成[ — ]
如题,正在调研规则引擎中,能否稍微给出与其他开源规则引擎的一些优缺点对比呢?
目前 'abc%' 也会匹配到 'babc',这和SQL的用法不一致,不够实用。
//(3)addFunction
ExpressRunner runner = new ExpressRunner();
DefaultContext<String, Object> context = new DefaultContext<String, Object>();
runner.addFunction("join",new JoinOperator());
Object r = runner.execute("join(1,2,3)", context, null, false, true);
System.out.println(r);
//返回结果 [1, 2, 3]
结果真的是[1,2,3]吗
17:26:37.341 [main] DEBUG com.ql.util.express.instruction.detail.Instruction - LoadData 1
17:26:37.341 [main] DEBUG com.ql.util.express.instruction.detail.Instruction - LoadData 2
17:26:37.341 [main] DEBUG com.ql.util.express.instruction.detail.Instruction - LoadData 3
17:26:37.341 [main] DEBUG com.ql.util.express.instruction.detail.Instruction - join(1,2,3)
[1, 2]
可以建一个群?
Time:23 ms - ID:com.midea.dataexporter.demo.mapper.UserMapper.selectList
Execute SQL:SELECT test_id AS id,name,age,test_type,test_date,role,phone,tenant_id FROM user
java.lang.RuntimeException: 没有实现方法:getObjectInner
at com.ql.util.express.instruction.opdata.OperateDataKeyValue.getObjectInner(OperateDataKeyValue.java:38)
OperatorEqualsLessMore 类
if (obj1 == null && obj2 == null) {
if (opStr.equals("==")) {
return true;
} else if (opStr.equals("!=") || opStr.equals("<>")) {
return false;
} else {
throw new Exception("两个空操作数不能执行这个操作:" + opStr);
}
} else if (obj1 == null || obj2 == null) {
if (opStr.equals("==")) {
return false;
} else if (opStr.equals("!=") || opStr.equals("<>")) {
return true;
} else {
throw new Exception("空操作数不能执行这个操作:" + opStr);
}
}
public static void main(String[] args) throws Exception {
ExpressRunner runner = new ExpressRunner();
DefaultContext<String, Object> context = new DefaultContext<String, Object>();
String express = "part = \"1@2@3\".split(\"@\");\n" +
"Integer.valueOf(part[2]);";
runner.execute(express, context, null, true, false);
}
执行这段代码会报这个错误
Caused by: java.lang.Exception: 没有找到java.lang.Class的方法:valueOf([Ljava.lang.String;)
at com.ql.util.express.instruction.op.OperatorMethod.executeInner(OperatorMethod.java:96)
at com.ql.util.express.instruction.op.OperatorBase.execute(OperatorBase.java:67)
at com.ql.util.express.instruction.detail.InstructionOperator.execute(InstructionOperator.java:44)
... 8 more
把express的内容改为
part = "1@2@3".split("@");
str = part[2];
Integer.valueOf(str);
就可以了
com.ql.util.express.ExpressRunner类线程安全么?
同时希望可以动态修改脚本中的函数时,引用此函数的脚本也感受到此函数的变化
有没有可能实现将配置规则web可视化的打算?或者将配置后的规则链表以树的形式展现
InstructionFactory的Map<String,InstructionFactory> instructionFactory 只看到有get , 没看到那里有put
public static InstructionFactory getInstructionFactory(String factory) {
try {
InstructionFactory result = instructionFactory.get(factory);
if (result == null) {
result = (InstructionFactory) Class.forName(factory)
.newInstance();
}
return result;
@Test
public void testChange_1() throws Exception {
ExpressRunner runner = RuleEngine.newInstance();
IExpressContext<String, Object> context = new DefaultContext<String, Object>();
context.put("test", 2.004);
String test = "if(test > 0){return 50}";
System.out.println(runner.execute(test, context, null, true, false));
String test1 = "if(test > 0){return -50}";
System.out.println(runner.execute(test1, context, null, true, false));
}
从测试用例得出test1执行失败,具体原因应该是在ExpressParse.transferWord2ExpressNode 对'-'这种特殊情况考虑不够。
return data.stream().filter(d -> d.getKey().equals("code") && Integer.parseInt(d.getValue()) > 200).count();
OR
return data.stream().filter(new Predicate() {
@OverRide
public boolean test(TabMonitorData tabMonitorData) {
return tabMonitorData.getKey().equals("code") && Integer.parseInt(tabMonitorData.getValue()) > 200;
}
}).count();
代码格式有些乱,建议format下
启动的时候报错:
Throwable Occurs during initialization! java.lang.NoClassDefFoundError: org/apache/commons/beanutils/BeanIntrospector#012 at java.lang.Class.forName0(Native Method)#12 at java.lang.Class.forName(Class.java:264)#12 at com.sun.proxy.$Proxy21.(Unknown Source)#12 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)#12 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)#12 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)#12 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)#12 at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:739)#12 at org.apache.commons.configuration2.builder.fluent.Parameters.createParametersProxy(Parameters.java:307)#12 at org.apache.commons.configuration2.builder.fluent.Parameters.fileBased(Parameters.java:186)#12 at org.apache.commons.configuration2.builder.fluent.Configurations.fileParams(Configurations.java:602)#12 at org.apache.commons.configuration2.builder.fluent.Configurations.fileParams(Configurations.java:614)#12 at org.apache.commons.configuration2.builder.fluent.Configurations.fileBasedBuilder(Configurations.java:132)#12 at org.apache.commons.configuration2.builder.fluent.Configurations.propertiesBuilder(Configurations.java:238)#12 at org.apache.commons.configuration2.builder.fluent.Configurations.properties(Configurations.java:282)#12 at me.ele.config.properties.PropertiesFetcher.buildPropertiesMap(PropertiesFetcher.java:257)#12 at me.ele.config.properties.PropertiesFetcher.buildDevFileMap(PropertiesFetcher.java:206)#12 at me.ele.config.properties.DevProperties.(DevProperties.java:18)#12 at me.ele.config.properties.DevProperties.(DevProperties.java:12)#12 at me.ele.config.properties.PropertiesFetcher.buildEnvHoldKey(PropertiesFetcher.java:160)#12 at me.ele.config.properties.PropertiesFetcher.buildSystemHoldMap(PropertiesFetcher.java:110)#12 at me.ele.config.properties.EnvProperties.(EnvProperties.java:14)#12 at me.ele.config.properties.EnvProperties.(EnvProperties.java:11)#12 at me.ele.config.ConfigFactory.(ConfigFactory.java:25)#12 at me.ele.pylon.core.PylonCore.lambda$new$0(PylonCore.java:97)#12 at me.ele.pylon.core.PylonCore.execute(PylonCore.java:294)#12 at me.ele.pylon.core.PylonCore.(PylonCore.java:94)#12 at me.ele.pylon.core.PylonCore.(PylonCore.java:63)#12 at me.ele.pylon.spring.extension.SOAContainerInitializer.postProcessBeanFactory(SOAContainerInitializer.java:37)#12 at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284)#12 at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174)#12 at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678)#12 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520)#12 at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:125)#12 at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)#12 at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:109)#12 at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:261)#12 at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)#12 at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)#12 at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)#12 at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)#12 at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)#12 at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228)#12 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:230)#12 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)#12 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)#12 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)#12 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:249)#12 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)#12 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)#12 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)#12 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)#12 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)#12 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)#12 at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)#12 at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)#12 at org.junit.runners.ParentRunner.run(ParentRunner.java:300)#12 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)#12 at org.junit.runner.JUnitCore.run(JUnitCore.java:157)#12 at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)#12 at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)#12 at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)#12 at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)#012Caused by: java.lang.ClassNotFoundException: org.apache.commons.beanutils.BeanIntrospector#012 at java.net.URLClassLoader.findClass(URLClassLoader.java:381)#12 at java.lang.ClassLoader.loadClass(ClassLoader.java:424)#12 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)#12 at java.lang.ClassLoader.loadClass(ClassLoader.java:357)#12 ... 63 common frames omitted#012
2018-12-28 17:59:34 INFO [main]: Going to exit with status(-1)!
Process finished with exit code 255
5: 2692930 64630320 com.ql.util.express.OperateData
6: 2692720 64625280 com.ql.util.express.instruction.detail.InstructionConstData
存在大量未回收对象,请问如何可以避免呢
runner.addMacro方法参数‘macroName’如果前缀是数字的话,会调用Integer.parseInt转换,导致报NumberFormatException异常,比如:'50元立减券',就会出现上述问题。
例如,如下测试:
@Test
public void testCharcharComapre() throws Exception {
ExpressRunner runner = new ExpressRunner();
String express = "'a'=='a' && '9.2'>='9.2' && '2018-05-09 17:47:31'>='2018-05-09 17:47:30'";
Boolean r = (Boolean) runner.execute(express, null, null, true, false);
assert r == true;
}
执行报以下错误:
java.lang.Exception: run QlExpress Exception at line 1 :
at com.ql.util.express.instruction.detail.InstructionOperator.execute(InstructionOperator.java:48)
at com.ql.util.express.InstructionSet.executeInnerOrigiInstruction(InstructionSet.java:204)
at com.ql.util.express.InstructionSet.excute(InstructionSet.java:170)
at com.ql.util.express.InstructionSetRunner.execute(InstructionSetRunner.java:59)
at com.ql.util.express.InstructionSetRunner.execute(InstructionSetRunner.java:46)
at com.ql.util.express.InstructionSetRunner.executeOuter(InstructionSetRunner.java:18)
at com.ql.util.express.ExpressRunner.execute(ExpressRunner.java:570)
at com.ql.util.express.ExpressRunner.execute(ExpressRunner.java:538)
at com.ql.util.express.example.OperatorTest.testCharcharComapre(OperatorTest.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.junit.runner.JUnitCore.run(JUnitCore.java:130)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.Exception: a和a不能执行compare 操作
at com.ql.util.express.Operator.compareData(Operator.java:66)
at com.ql.util.express.instruction.op.OperatorEqualsLessMore.executeInner(OperatorEqualsLessMore.java:50)
at com.ql.util.express.instruction.op.OperatorEqualsLessMore.executeInner(OperatorEqualsLessMore.java:25)
at com.ql.util.express.instruction.op.OperatorEqualsLessMore.executeInner(OperatorEqualsLessMore.java:21)
at com.ql.util.express.Operator.executeInner(Operator.java:20)
at com.ql.util.express.instruction.op.OperatorBase.execute(OperatorBase.java:67)
at com.ql.util.express.instruction.detail.InstructionOperator.execute(InstructionOperator.java:44)
... 29 more
例1
表达式为7<month &&month < 12
key为month
value为9
结果为false
例2
表达式为22<month
key为month
value为100
结果为false
例3
表达式为month < 89
key为month
value为9
结果为false
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.