Fixing null pointer exception when checking for plan name
@@ -26,6 +26,7 @@ import org.wso2.siddhi.core.ExecutionPlanRuntime;
import org.wso2.siddhi.core.SiddhiManager;
import org.wso2.siddhi.core.stream.input.InputHandler;
import org.wso2.siddhi.query.api.ExecutionPlan;
+import org.wso2.siddhi.query.api.annotation.Element;
import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException;
import org.wso2.siddhi.query.api.util.AnnotationHelper;
import org.wso2.siddhi.query.compiler.SiddhiCompiler;
@@ -47,12 +48,13 @@ public class StreamProcessorService {
public boolean deployExecutionPlan(String executionPlan) {
ExecutionPlan parsedExecutionPlan = SiddhiCompiler.parse(executionPlan);
- String executionPlanName = AnnotationHelper.getAnnotationElement(EventProcessorConstants.ANNOTATION_NAME_NAME,
- null, parsedExecutionPlan.
- getAnnotations()).getValue();
- if (executionPlanName == null || executionPlan.isEmpty()) {
+ Element nameAnnotation = AnnotationHelper.getAnnotationElement(EventProcessorConstants.ANNOTATION_NAME_NAME,
+ null, parsedExecutionPlan.getAnnotations());
+
+ if (nameAnnotation == null || nameAnnotation.getValue().isEmpty()) {
throw new ExecutionPlanValidationException("Execution plan name must be provided as @Plan:name('name').");
}
+ String executionPlanName = nameAnnotation.getValue();
if (!executionPlanRunTimeMap.containsKey(executionPlanName)) {
