DRILL-6063: Set correct ThreadContext ClassLoader before using Hadoop Configuration class in DrillClient
This closes #1079 Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/27aff35b Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/27aff35b Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/27aff35b Branch: refs/heads/master Commit: 27aff35b54df0adfd951c7b7afc47b36a6de5e0a Parents: 93621eb Author: Sorabh Hamirwasia <[email protected]> Authored: Tue Jan 2 10:35:19 2018 -0800 Committer: Parth Chandra <[email protected]> Committed: Mon Jan 8 17:28:59 2018 -0800 ---------------------------------------------------------------------- .../java/org/apache/drill/exec/rpc/user/UserClient.java | 11 +++++++++++ 1 file changed, 11 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/27aff35b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java index 2c63cbd..131febf 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java @@ -344,7 +344,18 @@ public class UserClient mechanismName = factory.getSimpleName(); logger.trace("Will try to authenticate to server using {} mechanism with encryption context {}", mechanismName, connection.getEncryptionCtxtString()); + + // Update the thread context class loader to current class loader + // See DRILL-6063 for detailed description + final ClassLoader oldThreadCtxtCL = Thread.currentThread().getContextClassLoader(); + final ClassLoader newThreadCtxtCL = this.getClass().getClassLoader(); + Thread.currentThread().setContextClassLoader(newThreadCtxtCL); + ugi = factory.createAndLoginUser(propertiesMap); + + // Reset the thread context class loader to original one + Thread.currentThread().setContextClassLoader(oldThreadCtxtCL); + saslClient = factory.createSaslClient(ugi, propertiesMap); if (saslClient == null) { throw new SaslException(String.format(
