public static synchronized boolean requiresExplosion()

in core/bootstrap/src/main/java/org/wildfly/swarm/bootstrap/modules/NestedJarResourceLoader.java [53:89]


    public static synchronized boolean requiresExplosion(URL base) throws IOException {
        try (AutoCloseable locateHandle = Performance.accumulate("Is explosion needed?")) {
            String urlString = base.toExternalForm();
            if (urlString.startsWith("jar:file:")) {
                int endLoc = urlString.indexOf(JAR_SUFFIX);
                if (endLoc > 0) {
                    String jarPath = urlString.substring(9, endLoc + 4);
                    //if it has spaces or other characters that would be URL encoded we need to decode them
                    jarPath = URLDecoder.decode(jarPath, StandardCharsets.UTF_8.name());

                    File exp = exploded.get(jarPath);
                    if (exp != null) {
                        return true;
                    }
                    if (explosionNotRequired.contains(jarPath)) {
                        return false;
                    }
                    try (JarFile jarFile = JarFiles.create(jarPath)) {
                        Enumeration<JarEntry> entries = jarFile.entries();
                        while (entries.hasMoreElements()) {
                            JarEntry each = entries.nextElement();
                            if (!each.isDirectory()) {
                                if (each.getName().startsWith("modules") && !each.getName().endsWith("/module.xml")) {
                                    return true;
                                }
                            }
                        }
                    }
                    explosionNotRequired.add(jarPath);
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        return false;
    }