1. getResources("jar:file:/Users/xxxxx/.gradle/caches/modules-2/files-2.1/com.example1/example1/1.0.0/92cc99358ea6b25f5b9981c2a3f04e595705403f/example2-1.0.0.jar!/com/example1/")
  2. field rootDirCache will cache jar:file:/Users/xxxxx/.gradle/caches/modules-2/files-2.1/com.example1/example1/1.0.0/92cc99358ea6b25f5b9981c2a3f04e595705403f/example2-1.0.0.jar!/com/example1/
  3. getResources("jar:file:/Users/xxxxx/.gradle/caches/modules-2/files-2.1/com.example2/example2/1.0.0/92cc99358ea6b25f5b9981c2a3f04e595705403f/example2-1.0.0.jar!/com/example2/")
  4. field rootDirCache will remove existingPath and put new path jar:file:/Users/xxxxx/.gradle/caches/modules-2/files-2.1/ causes FileNotFoundException

Link: https://github.com/spring-projects/spring-framework/commit/19fec0633fa9928d671e0bdda74ed7d26681f374#diff-69e11ca5877c77cb766565b03d43386f382f5321c62017d9e92f3615f6b3183eR605

Path judgment should be added to avoid caching invalid paths

Old

if (currentPrefix != null) {
    // A prefix match found, potentially to be turned into a common parent cache entry.
    if (commonPrefix == null || !commonUnique || currentPrefix.length() > commonPrefix.length()) {
        commonPrefix = currentPrefix;
        existingPath = path;
    }
    else if (currentPrefix.equals(commonPrefix)) {
        commonUnique = false;
    }
}

New

if (currentPrefix != null) {
    boolean startsWithJar = currentPrefix.startsWith("jar:");
    boolean containsJarExclamation = currentPrefix.contains(".jar!");
    if (startsWithJar && containsJarExclamation) {
        // A prefix match found, potentially to be turned into a common parent cache entry.
        if (commonPrefix == null || !commonUnique || currentPrefix.length() > commonPrefix.length()) {
            commonPrefix = currentPrefix;
            existingPath = path;
        }
        else if (currentPrefix.equals(commonPrefix)) {
            commonUnique = false;
        }
    }
}

Comment From: fangzhengjin

@jhoeller

Comment From: stephanie-dm

@jhoeller : When will this issue be fixed? We are currently blocked by it and had to rollback the update of Spring

Comment From: sbrannen

@stephanie-dm, as you can see on the right, this issue is scheduled for 6.2.2.

Comment From: jhoeller

@fangzhengjin @stephanie-dm this is available in the latest 6.2.2 snapshot now, please give it an early try if you have the chance (before 6.2.2 becomes generally available on Thursday).