-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClassLoader.getResource can throw IllegalArgumentException #26574
Conversation
Class.getResource, ClassLoader.getResource, and ClassLoader.getSystemResource will throw IllegalArgumentException if a malformed URL is provided to them. According to its javadoc, resolveURL should return null if not resolvable, so catch the IllegalArgumentException and return null.
I believe that this issue is caused by a bug in Java. Quoting the javadoc of java.lang.ClassLoader.getResource(String):
In this case, "a URL could not be constructed to locate the resource" so null should be returned. But that's not what's happening. I've reported this issue at https://bugreport.java.com/ (internal review ID : 9069151) and openjdk/jdk#2662 |
Class.getResource, ClassLoader.getResource, and ClassLoader.getSystemResource will throw IllegalArgumentException if a malformed URL is provided to them. According to its javadoc, resolveURL should return null if not resolvable, so catch the IllegalArgumentException and return null. Closes gh-26574
ClassLoader.getResource
can throwIllegalArgumentException
if a malformed URL is provided to it.According to its javadoc,
resolveURL
should return null if not resolvable, so catch theIllegalArgumentException
and return null.Example stack trace produced by
new org.springframework.core.io.DefaultResourceLoader().getResource("C:/users/candrews/example").exists()