spring-boot-maven-plugin:2.3.4.RELEASE
package test;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URLConnection;
@SpringBootApplication
public class App {
public static void main(String[] args) throws IOException {
URLConnection urlConnection = App.class.getResource("/test/App.class").openConnection();
if (urlConnection instanceof JarURLConnection) {
JarURLConnection jarURLConnection = (JarURLConnection) urlConnection;
// will case java.lang.IllegalStateException: zip file closed
jarURLConnection.getJarFile().stream();
}
}
}
The reason causing this problem is org.springframework.boot.loader.jar.JarFileWrapper not override method stream()