提交 9a5646b4 编写于 作者: T tianqiao

update runner.getOutFunctionNames nullPointer exception

上级 5f921d8d
......@@ -6,7 +6,7 @@
<groupId>com.taobao.util</groupId>
<artifactId>taobao-express</artifactId>
<packaging>jar</packaging>
<version>3.1.6</version>
<version>3.1.7</version>
<name>taobao-express</name>
<dependencies>
......
......@@ -99,17 +99,19 @@ public class InstructionSet implements Serializable{
if (instruction instanceof InstructionOperator) {
String opName = ((InstructionOperator) instruction)
.getOperator().getName();
if (opName.equalsIgnoreCase("def")
|| opName.equalsIgnoreCase("exportDef")) {
String varLocalName = (String) ((InstructionConstData) instructionList[i - 1])
.getOperateData().getObject(null);
result.remove(varLocalName);
} else if (opName.equalsIgnoreCase("alias")
|| opName.equalsIgnoreCase("exportAlias")) {
String varLocalName = (String) ((InstructionConstData) instructionList[i - 2])
.getOperateData().getObject(null);
result.remove(varLocalName);
}
if(opName != null){//addOperator(op)中op.name有可能为空
if (opName.equalsIgnoreCase("def")
|| opName.equalsIgnoreCase("exportDef")) {
String varLocalName = (String) ((InstructionConstData) instructionList[i - 1])
.getOperateData().getObject(null);
result.remove(varLocalName);
} else if (opName.equalsIgnoreCase("alias")
|| opName.equalsIgnoreCase("exportAlias")) {
String varLocalName = (String) ((InstructionConstData) instructionList[i - 2])
.getOperateData().getObject(null);
result.remove(varLocalName);
}
}
}
}
return result.keySet().toArray(new String[0]);
......
package com.ql.util.express.example;
import com.ql.util.express.DefaultContext;
import com.ql.util.express.ExpressRunner;
import com.ql.util.express.IExpressContext;
import com.ql.util.express.Operator;
import com.ql.util.express.*;
import com.ql.util.express.instruction.op.OperatorBase;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.junit.Test;
/**
......@@ -60,4 +60,50 @@ public class ArgumentTypeMismatchTest {
}
System.out.print("test ok!");
}
@Test
public void test3() throws Exception {
ExpressRunner runner = new ExpressRunner();
runner.addFunction("abc", new Operator() {
@Override
public Object executeInner(Object[] list) throws Exception {
Long paramA = Long.valueOf(list[0].toString());
Integer paramB = Integer.valueOf(list[1].toString());
String paramC = list[2].toString();
singleton.functionABC(paramA, paramB, paramC);
return null;
}
});
OperatorBase function = runner.getFunciton("abc");
System.out.println("function = " + ToStringBuilder.reflectionToString(function, ToStringStyle.MULTI_LINE_STYLE));
String exp = "abc(a,b,c)";
IExpressContext<String, Object> context = new DefaultContext<String, Object>();
context.put("a", "1");
context.put("b", "2");
context.put("c", "3");
InstructionSet instructionSet = runner.getInstructionSetFromLocalCache(exp);
String[] outFunctionNames = runner.getOutFunctionNames(exp);
String[] outVarNames = runner.getOutVarNames(exp);
System.out.println("before execute instructionSet = " + instructionSet);
System.out.println("outFunctionNames = " + ToStringBuilder.reflectionToString(outFunctionNames, ToStringStyle.MULTI_LINE_STYLE));
System.out.println("outVarNames = " + ToStringBuilder.reflectionToString(outVarNames, ToStringStyle.MULTI_LINE_STYLE));
try {
runner.execute(exp, context, null, false, false);
} catch (Exception e) {
e.printStackTrace();
}
instructionSet = runner.getInstructionSetFromLocalCache(exp);
outFunctionNames = runner.getOutFunctionNames(exp);
outVarNames = runner.getOutVarNames(exp);
System.out.println("after execute instructionSet = " + instructionSet);
System.out.println("outFunctionNames = " + ToStringBuilder.reflectionToString(outFunctionNames, ToStringStyle.MULTI_LINE_STYLE));
System.out.println("outVarNames = " + ToStringBuilder.reflectionToString(outVarNames, ToStringStyle.MULTI_LINE_STYLE));
System.out.println("test ok!");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册