Skip to content

ResourceUtils.extractArchiveURL fails to work under Tomcat 8.0.41 with unpackWARs=false [SPR-15556] #20115

@spring-projects-issues

Description

@spring-projects-issues

Alexey Veklov opened SPR-15556 and commented

Hi

It looks like ResourceUtils.extractArchiveURL also has an issue (Spring 4.3.8.RELEASE).

See comments in below snippet (marked with AV):

public static URL extractArchiveURL(URL jarUrl) throws MalformedURLException {
           // AV jarUrl = war:file:/C:/<...>.war*/<...>/<...>.css
     String urlFile = jarUrl.getFile();
           // AV urlFile = file:/C:/<...>.war*/<...>/<...>.css
     int endIndex = urlFile.indexOf(WAR_URL_SEPARATOR);
     if (endIndex != -1) {
          // Tomcat's "jar:war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt"
          String warFile = urlFile.substring(0, endIndex);
          int startIndex = warFile.indexOf(WAR_URL_PREFIX); // AV <-- startIndex == -1
          if (startIndex != -1) {
                    return new URL(warFile.substring(startIndex + WAR_URL_PREFIX.length()));
           }
      }
      // Regular "jar:file:...myjar.jar!/myentry.txt"
      return extractJarFileURL(jarUrl);
 }

Affects: 4.3.8

Issue Links:

Referenced from: commits c6deeb3, 7b3f5fd

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions