Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ public ManagedInterpreterGroup getInterpreterGroup(ExecutionContext executionCon
}

ManagedInterpreterGroup getInterpreterGroup(String groupId) {
if (groupId == null) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a warn log before returning in the null check so that this situation is more visible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning null could cause an NPE in the code currently calling this method (e.g., SessionConfInterpreter:53).
Therefore, I think it would be better to either not return null when groupId is null, or to modify the part that uses this method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your point, and I’d like to ask for a code update.
I found that ManagedInterpreterGroup getInterpreterGroup(String groupId) is used in two places: line 386 of InterpreterSettingManager.java and line 53 of SessionConfInterpreter.java.

In InterpreterSettingManager.java, null is already handled properly, but in SessionConfInterpreter.java it is not. Could you please update the code to handle null in that part as well?

}
return interpreterGroups.get(groupId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ public InterpreterResult interpret(String st, InterpreterContext context)
finalProperties.putAll(updatedProperties);
LOGGER.debug("Properties for Session: {}:{}", sessionId, finalProperties);

List<Interpreter> interpreters =
interpreterSetting.getInterpreterGroup(interpreterGroupId).get(sessionId);
InterpreterGroup interpreterGroup =
interpreterSetting.getInterpreterGroup(interpreterGroupId);
if (interpreterGroup == null) {
return new InterpreterResult(InterpreterResult.Code.ERROR,
"Can not find interpreter group " + interpreterGroupId);
}

List<Interpreter> interpreters = interpreterGroup.get(sessionId);
for (Interpreter intp : interpreters) {
// only check the RemoteInterpreter, ConfInterpreter itself will be ignored here.
if (intp instanceof RemoteInterpreter) {
Expand Down
Loading