Skip to content

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

Closed

Description

@tunefun

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

Activity

  1. added
    status: waiting-for-triage
    on Oct 23, 2020
  2. added
    type: bug
    and removed
    status: waiting-for-triage
    on Oct 23, 2020
  3. added this to the milestone on Oct 23, 2020
  4. self-assigned this
    on Oct 28, 2020
  5. modified the milestones: , on Nov 3, 2020
  6. wilkinsona commented on Nov 3, 2020

    @wilkinsona
    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.

  7. modified the milestones: , 2.3.6 on Nov 3, 2020
  8. added a commit that references this issue on Nov 3, 2020
    f3d4b3e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions