This is an automated email from the ASF dual-hosted git repository. dlmarion pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo-classloaders.git
The following commit(s) were added to refs/heads/main by this push: new db9d9af Fixes #4 - update ReloadingVFSContextClassLoaderFactory for upstream interface changes (#5) db9d9af is described below commit db9d9afc610c3e5b1aadd39a05ec67fcec0288d3 Author: Dave Marion <dlmar...@apache.org> AuthorDate: Fri Dec 4 11:02:43 2020 -0500 Fixes #4 - update ReloadingVFSContextClassLoaderFactory for upstream interface changes (#5) * Fixes #4 - update ReloadingVFSContextClassLoaderFactory for upstream interface changes --- .../context/ReloadingVFSContextClassLoaderFactory.java | 17 ++++++++++++++--- .../ReloadingVFSContextClassLoaderFactoryTest.java | 2 -- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/vfs-class-loader/src/main/java/org/apache/accumulo/classloader/vfs/context/ReloadingVFSContextClassLoaderFactory.java b/modules/vfs-class-loader/src/main/java/org/apache/accumulo/classloader/vfs/context/ReloadingVFSContextClassLoaderFactory.java index 9f73078..f5bebcc 100644 --- a/modules/vfs-class-loader/src/main/java/org/apache/accumulo/classloader/vfs/context/ReloadingVFSContextClassLoaderFactory.java +++ b/modules/vfs-class-loader/src/main/java/org/apache/accumulo/classloader/vfs/context/ReloadingVFSContextClassLoaderFactory.java @@ -19,7 +19,9 @@ package org.apache.accumulo.classloader.vfs.context; import java.io.File; +import java.io.IOException; import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.Files; import java.security.AccessController; import java.security.PrivilegedAction; @@ -28,7 +30,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.accumulo.classloader.vfs.AccumuloVFSClassLoader; -import org.apache.accumulo.core.client.PluginEnvironment.Configuration; import org.apache.accumulo.core.spi.common.ContextClassLoaderFactory; import org.apache.commons.io.FileUtils; import org.slf4j.Logger; @@ -245,6 +246,14 @@ public class ReloadingVFSContextClassLoaderFactory implements ContextClassLoader private static final Map<String,AccumuloVFSClassLoader> CONTEXTS = new ConcurrentHashMap<>(); private Contexts contextDefinitions = null; + public ReloadingVFSContextClassLoaderFactory() { + try { + initializeContexts(); + } catch (URISyntaxException | IOException e) { + throw new RuntimeException("Error initializing contexts", e); + } + } + protected String getConfigFileLocation() { String loc = System.getProperty(CONFIG_LOCATION); if (null == loc || loc.isBlank()) { @@ -254,8 +263,10 @@ public class ReloadingVFSContextClassLoaderFactory implements ContextClassLoader return loc; } - @Override - public void initialize(Configuration contextProperties) throws Exception { + private void initializeContexts() throws URISyntaxException, IOException { + if (!CONTEXTS.isEmpty()) { + LOG.debug("Contexts already initialized, skipping..."); + } // Properties String conf = getConfigFileLocation(); File f = new File(new URI(conf)); diff --git a/modules/vfs-class-loader/src/test/java/org/apache/accumulo/classloader/vfs/context/ReloadingVFSContextClassLoaderFactoryTest.java b/modules/vfs-class-loader/src/test/java/org/apache/accumulo/classloader/vfs/context/ReloadingVFSContextClassLoaderFactoryTest.java index 302b9b6..034cf8b 100644 --- a/modules/vfs-class-loader/src/test/java/org/apache/accumulo/classloader/vfs/context/ReloadingVFSContextClassLoaderFactoryTest.java +++ b/modules/vfs-class-loader/src/test/java/org/apache/accumulo/classloader/vfs/context/ReloadingVFSContextClassLoaderFactoryTest.java @@ -176,7 +176,6 @@ public class ReloadingVFSContextClassLoaderFactoryTest { return f.toURI().toString(); } }; - cl.initialize(null); try { cl.getClassLoader("c1"); fail("Expected illegal argument exception"); @@ -213,7 +212,6 @@ public class ReloadingVFSContextClassLoaderFactoryTest { return f.toURI().toString(); } }; - factory.initialize(null); ClassLoader cl1 = factory.getClassLoader("cx1"); Class<?> clazz1 = cl1.loadClass("test.HelloWorld");