Repository: zeppelin Updated Branches: refs/heads/master 8dd1fb184 -> 652911abe
[ZEPPELIN-2096] Conserve class loader after running interpret method ### What is this PR for? This PR is a follow-up PR of ZEPPELIN-1972. It keep context class loader while running interpret method by scala. For more information, please see https://issues.apache.org/jira/browse/ZEPPELIN-1972 ### What type of PR is it? [Feature] ### Todos * [x] - Backup and restore class loader around interpret method. ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-2096 ### How should this be tested? N/A ### Screenshots (if appropriate) N/A ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jongyoul Lee <jongy...@gmail.com> Closes #2258 from jongyoul/ZEPPELIN-2096 and squashes the following commits: 1eec19767 [Jongyoul Lee] Added logic to restore class loader after running interpret method Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/652911ab Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/652911ab Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/652911ab Branch: refs/heads/master Commit: 652911abe457d48a540be4a3de2dad824691dfb1 Parents: 8dd1fb1 Author: Jongyoul Lee <jongy...@gmail.com> Authored: Thu Apr 20 01:55:29 2017 +0900 Committer: Jongyoul Lee <jongy...@apache.org> Committed: Thu Apr 20 16:05:54 2017 +0900 ---------------------------------------------------------------------- .../org/apache/zeppelin/interpreter/LazyOpenInterpreter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/652911ab/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/LazyOpenInterpreter.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/LazyOpenInterpreter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/LazyOpenInterpreter.java index bb09d19..f1cbef8 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/LazyOpenInterpreter.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/LazyOpenInterpreter.java @@ -92,7 +92,12 @@ public class LazyOpenInterpreter @Override public InterpreterResult interpret(String st, InterpreterContext context) { open(); - return intp.interpret(st, context); + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + try { + return intp.interpret(st, context); + } finally { + Thread.currentThread().setContextClassLoader(classLoader); + } } @Override