Fix IndexOutOfBoundsException exception from parseUrl with empty spec
Update jar `Handler` code so that the `parseUrl` method can accept an
empty `spec`. Prior to this commit, a `classLoader.getResource("")`
call would result in a `null` result. This breaks a number of things
including `ClassPathResource` and `PathMatchingResourcePatternResolver`.
Fixes gh-38524
This commit is contained in:
@@ -89,7 +89,7 @@ public class Handler extends URLStreamHandler {
|
||||
|
||||
private String extractContextPath(URL url, String spec, int start) {
|
||||
String contextPath = url.getPath();
|
||||
if (spec.charAt(start) == '/') {
|
||||
if (spec.regionMatches(false, start, "/", 0, 1)) {
|
||||
int indexOfContextPathSeparator = indexOfSeparator(contextPath);
|
||||
if (indexOfContextPathSeparator == -1) {
|
||||
throw new IllegalStateException("malformed context url:%s: no !/".formatted(url));
|
||||
|
||||
Reference in New Issue
Block a user