@@ -118,23 +118,33 @@ public void setUp() throws Exception {
118118
119119 SessionState .setCurrentSessionState (ss );
120120
121- Configuration configuration = ApplicationProperties .get ();
121+ // SessionState.start swaps TCCL; align it with the Atlas client class loader for Jersey init.
122+ ClassLoader hiveTccl = Thread .currentThread ().getContextClassLoader ();
123+ ClassLoader atlasLoader = AtlasClientV2 .class .getClassLoader ();
122124
123- String [] atlasEndPoint = configuration . getStringArray ( HiveMetaStoreBridge . ATLAS_ENDPOINT );
125+ Thread . currentThread (). setContextClassLoader ( atlasLoader );
124126
125- if (atlasEndPoint == null || atlasEndPoint .length == 0 ) {
126- atlasEndPoint = new String [] { DGI_URL };
127- }
127+ try {
128+ Configuration configuration = ApplicationProperties .get ();
128129
129- if (!AuthenticationUtil .isKerberosAuthenticationEnabled ()) {
130- atlasClientV2 = new AtlasClientV2 (atlasEndPoint , new String []{"admin" , "admin" });
131- atlasClient = new AtlasClient (atlasEndPoint , new String []{"admin" , "admin" });
132- } else {
133- atlasClientV2 = new AtlasClientV2 (atlasEndPoint );
134- atlasClient = new AtlasClient (atlasEndPoint );
135- }
130+ String [] atlasEndPoint = configuration .getStringArray (HiveMetaStoreBridge .ATLAS_ENDPOINT );
131+
132+ if (atlasEndPoint == null || atlasEndPoint .length == 0 ) {
133+ atlasEndPoint = new String [] { DGI_URL };
134+ }
136135
137- hiveMetaStoreBridge = new HiveMetaStoreBridge (configuration , conf , atlasClientV2 );
136+ if (!AuthenticationUtil .isKerberosAuthenticationEnabled ()) {
137+ atlasClientV2 = new AtlasClientV2 (atlasEndPoint , new String []{"admin" , "admin" });
138+ atlasClient = new AtlasClient (atlasEndPoint , new String []{"admin" , "admin" });
139+ } else {
140+ atlasClientV2 = new AtlasClientV2 (atlasEndPoint );
141+ atlasClient = new AtlasClient (atlasEndPoint );
142+ }
143+
144+ hiveMetaStoreBridge = new HiveMetaStoreBridge (configuration , conf , atlasClientV2 );
145+ } finally {
146+ Thread .currentThread ().setContextClassLoader (hiveTccl );
147+ }
138148
139149 HiveConf conf = new HiveConf ();
140150
0 commit comments