Skip to content

Resources in /META-INF/ of executable-fat-jar would be fetched repeatedly. #16536

Closed
@QilongZhang

Description

@QilongZhang

When execute a Spring Boot Fat Jar,it's bootstrapped in AppClassLoader, actually switch to LaunchedURLClassLoader during refreshing application context.

As the parent of LaunchedURLClassLoader is AppClassLoader, it will lead resource in /META-INF/* of executable-fat-jar to be loaded repeatedly when invoke LaunchedURLClassLoader.getResources:

    public Enumeration<URL> getResources(String name) throws IOException {
        Objects.requireNonNull(name);
        @SuppressWarnings("unchecked")
        Enumeration<URL>[] tmp = (Enumeration<URL>[]) new Enumeration<?>[2];
        if (parent != null) {
            tmp[0] = parent.getResources(name);
        } else {
            tmp[0] = BootLoader.findResources(name);
        }
        tmp[1] = findResources(name);

        return new CompoundEnumeration<>(tmp);
    }

it leads our program failed to run!would you fix it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions