You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered a concurrent problem when using the toObject function. I spent a few hours checking the source code. And I realize a potential concurrency issue in class ToJSONObjectFunctionExtension.
JSONParser is created as a global variable in class ToJSONObjectFunctionExtension. When executing the execute(Object data, State state) function, the parse(data.toString()) function will be called with the input parameter. Everything looks good
private static final JSONParser jsonParser = new JSONParser(JSONParser.DEFAULT_PERMISSIVE_MODE); //global variable
//...
@Override
protected Object execute(Object data, State state) {
Object returnValue = null;
try {
returnValue = jsonParser.parse(data.toString());
} catch (ParseException e) {
log.error(siddhiQueryContext.getSiddhiAppContext().getName() + ":" + siddhiQueryContext.getName() +
": Cannot parse the given string into JSON. Hence returning null");
}
return returnValue;
}
Unfortunately, If you check function parse(String input) of class JSONParser, you will see the input parameter will be set to a global variable in class JSONParserString. In the case of multiple threads execution function execute(Object data, State state) at the same time, it will cause the concurrency issue.
I have encountered a concurrent problem when using the
toObject
function. I spent a few hours checking the source code. And I realize a potential concurrency issue in classToJSONObjectFunctionExtension
.JSONParser
is created as a global variable in classToJSONObjectFunctionExtension
. When executing theexecute(Object data, State state)
function, theparse(data.toString())
function will be called with the input parameter. Everything looks goodUnfortunately, If you check function
parse(String input)
of classJSONParser
, you will see the input parameter will be set to a global variable in classJSONParserString
. In the case of multiple threads execution functionexecute(Object data, State state)
at the same time, it will cause the concurrency issue.Version:
siddhi-execution-json 2.0.9
The text was updated successfully, but these errors were encountered: