Skip to content

Commit

Permalink
Merge pull request #1555 from thomasmey/work/tomcat
Browse files Browse the repository at this point in the history
Fix Tomcat URL handling fallout
  • Loading branch information
Axel Fontaine committed Apr 3, 2017
2 parents 9ea30f8 + cb23c13 commit b30ee80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Expand Up @@ -308,11 +308,16 @@ private ClassPathLocationScanner createLocationScanner(String protocol) {
}

if ("jar".equals(protocol)
|| "war".equals(protocol)
|| "war".equals(protocol) //Tomcat
|| "zip".equals(protocol) //WebLogic
|| "wsjar".equals(protocol) //WebSphere
) {
JarFileClassPathLocationScanner locationScanner = new JarFileClassPathLocationScanner();
JarFileClassPathLocationScanner locationScanner;
if ("war".equals(protocol)) {
locationScanner = new JarFileClassPathLocationScanner("*/");
} else {
locationScanner = new JarFileClassPathLocationScanner();
}
locationScannerCache.put(protocol, locationScanner);
resourceNameCache.put(locationScanner, new HashMap<URL, Set<String>>());
return locationScanner;
Expand Down
Expand Up @@ -30,6 +30,13 @@
* ClassPathLocationScanner for jar files.
*/
public class JarFileClassPathLocationScanner implements ClassPathLocationScanner {
private final String urlSeparator;
public JarFileClassPathLocationScanner() {
this("!/");
}
public JarFileClassPathLocationScanner(String urlSeparator) {
this.urlSeparator = urlSeparator;
}
public Set<String> findResourceNames(String location, URL locationUrl) throws IOException {
JarFile jarFile = getJarFromUrl(locationUrl);

Expand Down Expand Up @@ -64,7 +71,7 @@ private JarFile getJarFromUrl(URL locationUrl) throws IOException {
// We'll also handle paths with and without leading "file:" prefix.
String urlFile = locationUrl.getFile();

int separatorIndex = urlFile.indexOf("!/");
int separatorIndex = urlFile.indexOf(urlSeparator);
if (separatorIndex != -1) {
String jarFileUrl = urlFile.substring(0, separatorIndex);
if (jarFileUrl.startsWith("file:")) {
Expand Down

0 comments on commit b30ee80

Please sign in to comment.