Skip to content

Commit 29bd9b7

Browse files
committed
Encode hash symbol in jar file path (for compatibility with JDK 11+)
Closes gh-26104
1 parent f59f7cc commit 29bd9b7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -432,6 +432,9 @@ protected void addClassPathManifestEntries(Set<Resource> result) {
432432
// Possibly "c:" drive prefix on Windows, to be upper-cased for proper duplicate detection
433433
filePath = StringUtils.capitalize(filePath);
434434
}
435+
// # can appear in directories/filenames, java.net.URL should not treat it as a fragment
436+
filePath = StringUtils.replace(filePath, "#", "%23");
437+
// Build URL that points to the root of the jar file
435438
UrlResource jarResource = new UrlResource(ResourceUtils.JAR_URL_PREFIX +
436439
ResourceUtils.FILE_URL_PREFIX + filePath + ResourceUtils.JAR_URL_SEPARATOR);
437440
// Potentially overlapping with URLClassLoader.getURLs() result above!

0 commit comments

Comments
 (0)