Browse Source

Merge branch '6.2.x'

pull/34807/head
Juergen Hoeller 9 months ago
parent
commit
014a395aed
  1. 15
      spring-core/src/main/java/org/springframework/core/io/AbstractFileResolvingResource.java

15
spring-core/src/main/java/org/springframework/core/io/AbstractFileResolvingResource.java

@ -29,6 +29,7 @@ import java.nio.channels.ReadableByteChannel; @@ -29,6 +29,7 @@ import java.nio.channels.ReadableByteChannel;
import java.nio.file.NoSuchFileException;
import java.nio.file.StandardOpenOption;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.springframework.util.ResourceUtils;
@ -44,6 +45,7 @@ import org.springframework.util.ResourceUtils; @@ -44,6 +45,7 @@ import org.springframework.util.ResourceUtils;
*/
public abstract class AbstractFileResolvingResource extends AbstractResource {
@SuppressWarnings("try")
@Override
public boolean exists() {
try {
@ -86,15 +88,10 @@ public abstract class AbstractFileResolvingResource extends AbstractResource { @@ -86,15 +88,10 @@ public abstract class AbstractFileResolvingResource extends AbstractResource {
if (con instanceof JarURLConnection jarCon) {
// For JarURLConnection, do not check content-length but rather the
// existence of the entry (or the jar root in case of no entryName).
try {
if (jarCon.getEntryName() == null) {
// Jar root: check for the existence of any actual jar entries.
return jarCon.getJarFile().entries().hasMoreElements();
}
return (jarCon.getJarEntry() != null);
}
finally {
jarCon.getJarFile().close();
// getJarFile() called for enforced presence check of the jar file,
// throwing a NoSuchFileException otherwise (turned to false below).
try (JarFile jarFile = jarCon.getJarFile()) {
return (jarCon.getEntryName() == null || jarCon.getJarEntry() != null);
}
}
else if (con.getContentLengthLong() > 0) {

Loading…
Cancel
Save