elharo commented on code in PR #105:
URL: https://github.com/apache/maven-shared-io/pull/105#discussion_r3525206763


##########
src/test/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategyTest.java:
##########
@@ -47,6 +47,23 @@ void shouldFailToResolveMissingClasspathResource() {
         assertEquals(1, mh.size());
     }
 
+    @Test
+    void shouldFailToResolveWhenContextClassLoaderIsNull() {
+        Thread thread = Thread.currentThread();
+        ClassLoader contextClassLoader = thread.getContextClassLoader();
+        MessageHolder mh = new DefaultMessageHolder();

Review Comment:
   mh --> messageHolder



##########
src/main/java/org/apache/maven/shared/io/location/ClasspathResourceLocatorStrategy.java:
##########
@@ -55,7 +55,7 @@ public ClasspathResourceLocatorStrategy(
     public Location resolve(String locationSpecification, MessageHolder 
messageHolder) {
         ClassLoader cloader = Thread.currentThread().getContextClassLoader();
 
-        URL resource = cloader.getResource(locationSpecification);
+        URL resource = cloader != null ? 
cloader.getResource(locationSpecification) : null;

Review Comment:
   This isn't right. If getContextClassLoader() returns null, you should use 
the system classloader.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to