You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/01/03 00:14:00 UTC

[jira] [Commented] (DRILL-6063) Set correct ThreadContext ClassLoader before using Hadoop Configuration class in DrillClient

    [ https://issues.apache.org/jira/browse/DRILL-6063?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16308914#comment-16308914 ] 

ASF GitHub Bot commented on DRILL-6063:
---------------------------------------

GitHub user sohami opened a pull request:

    https://github.com/apache/drill/pull/1079

    DRILL-6063: Set correct ThreadContext ClassLoader before using Hadoop…

    … Configuration class in DrillClient

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/sohami/drill DRILL-6063

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/drill/pull/1079.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1079
    
----
commit e7a7273df06f0602c6ca154297b2db01a1181c33
Author: Sorabh Hamirwasia <sh...@...>
Date:   2018-01-02T18:35:19Z

    DRILL-6063: Set correct ThreadContext ClassLoader before using Hadoop Configuration class in DrillClient

----


> Set correct ThreadContext ClassLoader before using Hadoop Configuration class in DrillClient
> --------------------------------------------------------------------------------------------
>
>                 Key: DRILL-6063
>                 URL: https://issues.apache.org/jira/browse/DRILL-6063
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Client - Java
>    Affects Versions: 1.11.0
>            Reporter: Sorabh Hamirwasia
>            Assignee: Sorabh Hamirwasia
>
> Drill Client uses Hadoop Configuration class in security mechanism factories. Configuration class internally uses ThreadContext class loader to get the default resources for configurations. When Drill JDBC driver is used with 3rd party tool like Squirrel then it creates a class loader with all Drill Driver related dependencies. This class loader is used to instantiate an object of Driver class in a separate thread. But the thread context class loader has dependencies related to Squirrel only. As a result of this when Hadoop Configuration class tries to load the resources with default values it doesn't find them in class path.
> If we specify hadoop dependencies in Squirrel's classpath instead of Driver dependencies class path then it will work since Thread Context class loader will have Hadoop libraries loaded too and will find the resources. But this is not good as it is tying up one Squirrel instance with one version of Hadoop which might not be true in all the cases like here when same Squirrel instance can be used to load multiple versions of Drill Driver having different hadoop version dependencies.
> To deal with this issue a simple fix is to set the Thread Context class loader to be same as Drill Driver dependencies class loader before accessing Hadoop Configuration class in Drill Client and later restore it back.
> Some pointers in code:
> * Place where JDBC driver is loaded as part of separate thread in Squirrel: [OpenConnectionCommand.java|https://sourceforge.net/p/squirrel-sql/git/ci/master/tree/sql12/core/src/net/sourceforge/squirrel_sql/client/mainframe/action/OpenConnectionCommand.java#l167]
> * Place where JDBC driver class is instantiated in Squirrel using Driver dependencies class loader: [SQLDriverManager.java|https://sourceforge.net/p/squirrel-sql/git/ci/master/tree/sql12/core/src/net/sourceforge/squirrel_sql/fw/sql/SQLDriverManager.java#l74]
> * Place where Hadoop Configuration class looks into Thread Context Class Loader: [Configuration.java|https://github.com/apache/hadoop-common/blob/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java#L615]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)