Skip to content

"java.lang.IllegalStateException: zip file closed" when call JarFileWrapper.stream() of spring-boot-loader #23821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tunefun opened this issue Oct 23, 2020 · 1 comment
Assignees
Labels
type: bug A general bug
Milestone

Comments

@tunefun
Copy link

tunefun commented Oct 23, 2020

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 23, 2020
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 23, 2020
@wilkinsona wilkinsona added this to the 2.2.x milestone Oct 23, 2020
@philwebb philwebb self-assigned this Oct 28, 2020
@wilkinsona wilkinsona assigned wilkinsona and unassigned philwebb Nov 3, 2020
@wilkinsona wilkinsona modified the milestones: 2.2.x, 2.3.x Nov 3, 2020
@wilkinsona
Copy link
Member

This problem was reported against 2.3 and our JarFile only started overriding stream() in 2.3 (ed7a5db). 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants