Upgrade from Junit4 to Junit5
diff --git a/modules/vfs-class-loader/TESTING.md b/modules/vfs-class-loader/TESTING.md
index c15998f..9273679 100644
--- a/modules/vfs-class-loader/TESTING.md
+++ b/modules/vfs-class-loader/TESTING.md
@@ -46,11 +46,15 @@
Stop Accumulo if it's running and add the following to the accumulo-env.sh:
+**Note:** Make sure the commons-vfs2 jar is also on the classpath as well. This dependency was removed in Accumulo 3.0.0
+so if using that version or newer you will need to add it.
+
```
a. Add vfs-reloading-classloader-1.0.0-SNAPSHOT.jar to CLASSPATH
-b. Add "-Djava.system.class.loader=org.apache.accumulo.classloader.vfs.AccumuloVFSClassLoader" to JAVA_OPTS
-c. Add "-Dvfs.class.loader.classpath=hdfs://localhost:9000/iterators/system/.*" to JAVA_OPTS
-d. Add "-Dvfs.classpath.monitor.seconds=10" to JAVA_OPTS
+b. (if not already on classpath) Add commons-vfs2-<version>.jar to CLASSPATH
+c. Add "-Djava.system.class.loader=org.apache.accumulo.classloader.vfs.AccumuloVFSClassLoader" to JAVA_OPTS
+d. Add "-Dvfs.class.loader.classpath=hdfs://localhost:9000/iterators/system/.*" to JAVA_OPTS
+e. Add "-Dvfs.classpath.monitor.seconds=10" to JAVA_OPTS
e. (optional) Add "-Dvfs.class.loader.debug=true" to JAVA_OPTS
```
@@ -66,7 +70,7 @@
scan
```
-## Setting scan context on table (Legacy)
+## Setting scan context on table (Legacy, only works on Accumulo 2.1.0 and older)
### Define a Table Context and load the iterator class with the same name, but different behavior
@@ -158,11 +162,11 @@
scan
```
-## Setting scan context on table (New)
+## Setting scan context on table (Accumulo 3.0.0 and newer)
For this test we will use the new ReloadingVFSContextClassLoaderFactory for the table context classloaders.
-a. First, let's clean up from the prior tests
+a. First, let's clean up from the prior tests (**Note:** this does not apply if running Accumulo 3.0.0)
```
droptable -f test
@@ -172,7 +176,7 @@
config -d general.vfs.context.classpath.cx2.delegation
```
-b. Then, create a file on the local filesystem for the context configuration.
+a. Then, create a file on the local filesystem for the context configuration.
```
{
@@ -224,6 +228,15 @@
a. Set the table context to cxA. The scan on the table should return the value `foo`.
+**Note:** The property for the context was renamed in Accumulo 3.0.0
+
+Accumulo 3.0.0
+```
+config -t test -s table.class.loader.context=cxA
+scan
+```
+
+Accumulo 2.1.0
```
config -t test -s table.classpath.context=cxA
scan
@@ -231,6 +244,13 @@
b. Set the table context to cxB. The scan on the table should return the value `bar`.
+Accumulo 3.0.0
+```
+config -t test -s table.class.loader.context=cxB
+scan
+```
+
+Accumulo 2.1.0
```
config -t test -s table.classpath.context=cxB
scan
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 f5bebcc..7a546e9 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
@@ -23,8 +23,6 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -37,6 +35,8 @@
import com.google.gson.Gson;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
/**
* A ClassLoaderFactory implementation that uses a ReloadingVFSClassLoader per defined context.
* Configuration of this class is done with a JSON file whose location is defined by the system
@@ -282,39 +282,35 @@
});
}
+ @SuppressFBWarnings(value = "DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED",
+ justification = "Security Manager is deprecated for removal as of JDK 17")
protected AccumuloVFSClassLoader create(Context c) {
LOG.debug("Creating ReloadingVFSClassLoader for context: {})", c.getName());
- return AccessController.doPrivileged(new PrivilegedAction<AccumuloVFSClassLoader>() {
+ return new AccumuloVFSClassLoader(
+ ReloadingVFSContextClassLoaderFactory.class.getClassLoader()) {
@Override
- public AccumuloVFSClassLoader run() {
- return new AccumuloVFSClassLoader(
- ReloadingVFSContextClassLoaderFactory.class.getClassLoader()) {
- @Override
- protected String getClassPath() {
- return c.getConfig().getClassPath();
- }
-
- @Override
- protected boolean isPostDelegationModel() {
- LOG.debug("isPostDelegationModel called, returning {}",
- c.getConfig().getPostDelegate());
- return c.getConfig().getPostDelegate();
- }
-
- @Override
- protected long getMonitorInterval() {
- return c.getConfig().getMonitorIntervalMs();
- }
-
- @Override
- protected boolean isVMInitialized() {
- // The classloader is not being set using
- // `java.system.class.loader`, so the VM is initialized.
- return true;
- }
- };
+ protected String getClassPath() {
+ return c.getConfig().getClassPath();
}
- });
+
+ @Override
+ protected boolean isPostDelegationModel() {
+ LOG.debug("isPostDelegationModel called, returning {}", c.getConfig().getPostDelegate());
+ return c.getConfig().getPostDelegate();
+ }
+
+ @Override
+ protected long getMonitorInterval() {
+ return c.getConfig().getMonitorIntervalMs();
+ }
+
+ @Override
+ protected boolean isVMInitialized() {
+ // The classloader is not being set using
+ // `java.system.class.loader`, so the VM is initialized.
+ return true;
+ }
+ };
}
@Override
diff --git a/modules/vfs-class-loader/src/test/java/org/apache/accumulo/classloader/vfs/VfsClassLoaderTest.java b/modules/vfs-class-loader/src/test/java/org/apache/accumulo/classloader/vfs/VfsClassLoaderTest.java
index 15998ea..a3bbb4e 100644
--- a/modules/vfs-class-loader/src/test/java/org/apache/accumulo/classloader/vfs/VfsClassLoaderTest.java
+++ b/modules/vfs-class-loader/src/test/java/org/apache/accumulo/classloader/vfs/VfsClassLoaderTest.java
@@ -23,8 +23,6 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.Arrays;
import org.apache.commons.vfs2.FileChangeEvent;
@@ -82,17 +80,14 @@
FileObject[] dirContents = testDir.getChildren();
LOG.info("Test directory contents according to VFS: {}", Arrays.toString(dirContents));
- VFSClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<VFSClassLoader>() {
- @Override
- public VFSClassLoader run() {
- // Point the VFSClassLoader to all of the objects in TEST_DIR
- try {
- return new VFSClassLoader(dirContents, vfs);
- } catch (FileSystemException e) {
- throw new RuntimeException("Error creating VFSClassLoader", e);
- }
- }
- });
+ final VFSClassLoader cl;
+
+ // Point the VFSClassLoader to all of the objects in TEST_DIR
+ try {
+ cl = new VFSClassLoader(dirContents, vfs);
+ } catch (FileSystemException e) {
+ throw new RuntimeException("Error creating VFSClassLoader", e);
+ }
LOG.info("VFSClassLoader has the following files: {}", Arrays.toString(cl.getFileObjects()));
LOG.info("Looking for HelloWorld.class");
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 1d9a44a..0bb9dd2 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
@@ -28,8 +28,6 @@
import java.io.BufferedWriter;
import java.io.File;
import java.nio.file.Files;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.List;
@@ -64,43 +62,37 @@
this.dir = dir;
}
+ @SuppressFBWarnings(value = "DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED",
+ justification = "Security Manager is deprecated for removal as of JDK 17")
@Override
protected AccumuloVFSClassLoader create(Context c) {
- AccumuloVFSClassLoader acl =
- AccessController.doPrivileged(new PrivilegedAction<AccumuloVFSClassLoader>() {
+ final AccumuloVFSClassLoader cl =
+ new AccumuloVFSClassLoader(ReloadingVFSContextClassLoaderFactory.class.getClassLoader()) {
@Override
- public AccumuloVFSClassLoader run() {
- AccumuloVFSClassLoader cl = new AccumuloVFSClassLoader(
- ReloadingVFSContextClassLoaderFactory.class.getClassLoader()) {
- @Override
- protected String getClassPath() {
- return dir;
- }
-
- @Override
- protected boolean isPostDelegationModel() {
- LOG.debug("isPostDelegationModel called, returning {}",
- c.getConfig().getPostDelegate());
- return c.getConfig().getPostDelegate();
- }
-
- @Override
- protected long getMonitorInterval() {
- return 500l;
- }
-
- @Override
- protected boolean isVMInitialized() {
- return true;
- }
- };
- cl.setVMInitializedForTests();
- cl.setMaxRetries(2);
- return cl;
+ protected String getClassPath() {
+ return dir;
}
- });
- return acl;
+ @Override
+ protected boolean isPostDelegationModel() {
+ LOG.debug("isPostDelegationModel called, returning {}",
+ c.getConfig().getPostDelegate());
+ return c.getConfig().getPostDelegate();
+ }
+
+ @Override
+ protected long getMonitorInterval() {
+ return 500l;
+ }
+
+ @Override
+ protected boolean isVMInitialized() {
+ return true;
+ }
+ };
+ cl.setVMInitializedForTests();
+ cl.setMaxRetries(2);
+ return cl;
}
}
diff --git a/modules/vfs-class-loader/src/test/shell/makeHelloWorldJars.sh b/modules/vfs-class-loader/src/test/shell/makeHelloWorldJars.sh
index 04289ec..fcf4e8d 100755
--- a/modules/vfs-class-loader/src/test/shell/makeHelloWorldJars.sh
+++ b/modules/vfs-class-loader/src/test/shell/makeHelloWorldJars.sh
@@ -26,8 +26,10 @@
sed "s/%%/Hello World\!/" < src/test/java/test/HelloWorldTemplate > target/generated-sources/HelloWorld/test/HelloWorld.java
$JAVA_HOME/bin/javac target/generated-sources/HelloWorld/test/HelloWorld.java -d target/generated-sources/HelloWorld
$JAVA_HOME/bin/jar -cf target/test-classes/HelloWorld.jar -C target/generated-sources/HelloWorld test/HelloWorld.class
+rm -r target/generated-sources/HelloWorld/test
mkdir -p target/generated-sources/HalloWelt/test
sed "s/%%/Hallo Welt/" < src/test/java/test/HelloWorldTemplate > target/generated-sources/HalloWelt/test/HelloWorld.java
$JAVA_HOME/bin/javac target/generated-sources/HalloWelt/test/HelloWorld.java -d target/generated-sources/HalloWelt
$JAVA_HOME/bin/jar -cf target/test-classes/HelloWorld2.jar -C target/generated-sources/HalloWelt test/HelloWorld.class
+rm -r target/generated-sources/HalloWelt/test
diff --git a/modules/vfs-class-loader/src/test/shell/makeTestJars.sh b/modules/vfs-class-loader/src/test/shell/makeTestJars.sh
index fc86fb7..5d26bb1 100755
--- a/modules/vfs-class-loader/src/test/shell/makeTestJars.sh
+++ b/modules/vfs-class-loader/src/test/shell/makeTestJars.sh
@@ -29,4 +29,5 @@
sed "s/testX/test$x/" < src/test/java/test/TestTemplate > target/generated-sources/$x/test/TestObject.java
$JAVA_HOME/bin/javac -cp target/test-classes target/generated-sources/$x/test/TestObject.java -d target/generated-sources/$x
$JAVA_HOME/bin/jar -cf target/test-classes/ClassLoaderTest$x/Test.jar -C target/generated-sources/$x test/TestObject.class
+ rm -r target/generated-sources/$x
done
diff --git a/pom.xml b/pom.xml
index 1bf63d1..c584472 100644
--- a/pom.xml
+++ b/pom.xml
@@ -288,7 +288,7 @@
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
- <version>1.4.1</version>
+ <version>1.8.0</version>
<configuration>
<removeUnused>true</removeUnused>
<groups>java.,javax.,org.,com.</groups>
@@ -495,7 +495,7 @@
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
- <version>2.1.0</version>
+ <version>2.5.0</version>
<configuration>
<javaVersion>${maven.compiler.target}</javaVersion>
</configuration>