Skip to content

Commit d091354

Browse files
proceaneParkGyeongTae
authored andcommitted
[ZEPPELIN-6282] Add null check condition
### What is this PR for? This PR was created to prevent an error that occurs in the `InterpreterSetting.getInterpreterGroup` method when `groupId` is null and is retrieved from the Set. Normally, the groupId parameter does not seem to be passed as null. I found it when tested service shutdown(#4965). ### What type of PR is it? Improvement ### Todos * [x] - Add null check condition ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-6282 ### How should this be tested? ### Screenshots (if appropriate) ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes #5026 from proceane/feature/ZEPPELIN-6282. Signed-off-by: ParkGyeongTae <[email protected]> (cherry picked from commit 078b754) Signed-off-by: ParkGyeongTae <[email protected]>
1 parent dfff680 commit d091354

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ public ManagedInterpreterGroup getInterpreterGroup(ExecutionContext executionCon
491491
}
492492

493493
ManagedInterpreterGroup getInterpreterGroup(String groupId) {
494+
if (groupId == null) {
495+
return null;
496+
}
494497
return interpreterGroups.get(groupId);
495498
}
496499

zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/SessionConfInterpreter.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,14 @@ public InterpreterResult interpret(String st, InterpreterContext context)
4949
finalProperties.putAll(updatedProperties);
5050
LOGGER.debug("Properties for Session: {}:{}", sessionId, finalProperties);
5151

52-
List<Interpreter> interpreters =
53-
interpreterSetting.getInterpreterGroup(interpreterGroupId).get(sessionId);
52+
InterpreterGroup interpreterGroup =
53+
interpreterSetting.getInterpreterGroup(interpreterGroupId);
54+
if (interpreterGroup == null) {
55+
return new InterpreterResult(InterpreterResult.Code.ERROR,
56+
"Can not find interpreter group " + interpreterGroupId);
57+
}
58+
59+
List<Interpreter> interpreters = interpreterGroup.get(sessionId);
5460
for (Interpreter intp : interpreters) {
5561
// only check the RemoteInterpreter, ConfInterpreter itself will be ignored here.
5662
if (intp instanceof RemoteInterpreter) {

0 commit comments

Comments
 (0)