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()

Comment From: wilkinsona

This problem was reported against 2.3 and our JarFile only started overriding stream() in 2.3 (https://github.com/spring-projects/spring-boot/commit/ed7a5db17441bdb37df8e90dc0fa6c52948c008e). For consistency, I think we should make the same change to JarFileWrapper in 2.3.x as well. If needs be, the relevant parts of both changes could be back ported to 2.2.x in the future.