mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Prashant
12 hours ago 077abc8699cb5915a888a30d0d3f7c4b4ef88ac3
Close extension jars and manifests read by ConfigurationFramework (#1314)
1 files modified
27 ■■■■■ changed files
opendj-config/src/main/java/org/forgerock/opendj/config/ConfigurationFramework.java 27 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/ConfigurationFramework.java
@@ -439,6 +439,21 @@
    private void addExtension(final List<File> extensions) throws ConfigException {
        // First add the Jar files to the class loader.
        final List<JarFile> jars = new LinkedList<>();
        try {
            addExtension(extensions, jars);
        } finally {
            // Only read for their manifests: the class loader opens the jars on its own.
            for (final JarFile jar : jars) {
                try {
                    jar.close();
                } catch (final IOException e) {
                    debugLogger.trace("Unable to close jar file: " + jar.getName(), e);
                }
            }
        }
    }
    private void addExtension(final List<File> extensions, final List<JarFile> jars) throws ConfigException {
        for (final File extension : extensions) {
            if (jarFiles.contains(extension)) {
                // Skip this file as it is already loaded.
@@ -546,8 +561,10 @@
        if (is == null) {
            throw new ConfigException(ERR_ADMIN_CANNOT_FIND_CORE_MANIFEST.get(MANIFEST_ABSOLUTE_PATH));
        }
        try {
            loadDefinitionClasses(is);
        try (InputStream manifest = is) {
            loadDefinitionClasses(manifest);
        } catch (final IOException e) {
            debugLogger.trace("Unable to close the core manifest", e);
        } catch (final ConfigException e) {
            debugLogger.trace("Unable to initialize core components", e);
            throw new ConfigException(ERR_CLASS_LOADER_CANNOT_LOAD_CORE.get(
@@ -580,8 +597,10 @@
                throw new ConfigException(message);
            }
            try {
                loadDefinitionClasses(is);
            try (InputStream manifest = is) {
                loadDefinitionClasses(manifest);
            } catch (final IOException e) {
                debugLogger.trace("Unable to close the extension manifest", e);
            } catch (final ConfigException e) {
                debugLogger.trace("Unable to load classes from input stream", e);
                final LocalizableMessage message = ERR_CLASS_LOADER_CANNOT_LOAD_EXTENSION.get(