wchevreuil commented on issue #1207: HBASE-23892 KeyStoreTestUtil.getClasspathDir NPE when running UT exte… URL: https://github.com/apache/hbase/pull/1207#issuecomment-591912867 > Can you share the top of the stack-trace -- what your test code calls and how that filters down into the hbase code here? The test code extends **SecureTestCluster**, so when **SecureTestCluster.setup** runs, it calls **HBaseKerberosUtils.setSSLConfiguration** passing its own class reference [here](https://github.com/apache/hbase/blob/master/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/SecureTestCluster.java#L72). **HBaseKerberosUtils.setSSLConfiguration**, in turn, calls **KeyStoreTestUtil.getClasspathDir** [here](https://github.com/apache/hbase/blob/master/hbase-server/src/test/java/org/apache/hadoop/hbase/security/HBaseKerberosUtils.java#L173). **KeyStoreTestUtil.getClasspathDir** uses the passed class reference name to look for its related resource in the class loader. [This line](https://github.com/apache/hbase/blob/master/hbase-http/src/test/java/org/apache/hadoop/hbase/http/ssl/KeyStoreTestUtil.java#L58) returns an URL value as follows, when the passed class reference resource resides on jar file in the class loader (instead of being in a valid local FS path): `jar:file:/Users/wellingtonchevreuil/.m2/repository/org/apache/hbase/hbase-server/2.2.3./hbase-server-2.2.3-tests.jar!/org/apache/hadoop/hbase/security/token/SecureTestCluster.class` This causes [subsequent line](https://github.com/apache/hbase/blob/master/hbase-http/src/test/java/org/apache/hadoop/hbase/http/ssl/KeyStoreTestUtil.java#L59) calling `url.toURI().getPath()` to return null, then we get the NPE thrown in the following line, and the test errors out: `java.lang.NullPointerException at org.apache.hadoop.hbase.http.ssl.KeyStoreTestUtil.getClasspathDir(KeyStoreTestUtil.java:59) at org.apache.hadoop.hbase.security.HBaseKerberosUtils.setSSLConfiguration(HBaseKerberosUtils.java:173) at org.apache.hadoop.hbase.security.token.SecureTestCluster.setUp(SecureTestCluster.java:74) at com.cloudera.hbase.security.token.TestCldrManualDelegationToken.setUp(TestCldrManualDelegationToken.java:168) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292) at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) at java.util.concurrent.FutureTask.run(FutureTask.java) at java.lang.Thread.run(Thread.java:748)` > Can we fix the test-API such that the downstream code has the hook to provide a class which will actually get a classloader from test-classes instead of the jar? I can think of defining a protected static `Class` instance in **SecureTestCluster** whose default value would be `SecureTestCluster.class`, then pass that **HBaseKerberosUtils.setSSLConfiguration** so that downstream sub-classes of **SecureTestCluster** could override that property with its own values. Let me update this PR with this option.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
