gnodet commented on code in PR #1945:
URL: https://github.com/apache/maven-resolver/pull/1945#discussion_r3537257323


##########
maven-resolver-named-locks-ipc/src/main/java/org/eclipse/aether/named/ipc/IpcClient.java:
##########
@@ -262,7 +263,15 @@ SocketChannel createClient() throws IOException {
     private String getJarPath(Class<?> clazz) {
         String classpath;
         String className = clazz.getName().replace('.', '/') + ".class";
-        String url = clazz.getClassLoader().getResource(className).toString();
+        ClassLoader classLoader = clazz.getClassLoader();
+        if (classLoader == null) {
+            classLoader = ClassLoader.getSystemClassLoader();
+        }
+        URL resource = classLoader.getResource(className);
+        if (resource == null) {
+            throw new IllegalStateException("Unable to find resource for class 
" + clazz.getName());
+        }

Review Comment:
   `IllegalStateException` is consistent with the two existing throws in the 
same method (lines 280 and 285) for other unrecoverable URL format conditions. 
The caller at line 176 is inside a `catch (Exception e) { throw new 
RuntimeException("Unable to create and connect to lock server", e) }` block 
(line 257), so the exception is always caught and wrapped with context — 
nothing is bypassed.



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