This is an automated email from the ASF dual-hosted git repository.

ctubbsii 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 8fcfd77  Simplify file names for downloaded definitions (#41)
8fcfd77 is described below

commit 8fcfd772d043e1ed58b7feb88960e8a0e100de22
Author: Christopher Tubbs <[email protected]>
AuthorDate: Wed Jan 14 18:59:40 2026 -0500

    Simplify file names for downloaded definitions (#41)
    
    * Use checksum.json instead of attempting to track the original file
      name in the remote URL for the context definition
    * This avoids weird edge cases, like when an HTTP url for a context
      definition ends with /, which is a valid HTTP url, but has no
      associated file name to parse out
    * This also prevents duplicate local copies of the same context
      definition downloaded from different source URLs
---
 .../lcc/LocalCachingContextClassLoaderFactory.java |  4 +-
 .../lcc/definition/ContextDefinition.java          | 23 ++-------
 .../accumulo/classloader/lcc/util/LocalStore.java  | 12 ++---
 .../LocalCachingContextClassLoaderFactoryTest.java | 50 +++++++++----------
 .../MiniAccumuloClusterClassLoaderFactoryTest.java |  6 +--
 .../classloader/lcc/util/LocalStoreTest.java       | 58 +++++++++++-----------
 6 files changed, 66 insertions(+), 87 deletions(-)

diff --git 
a/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactory.java
 
b/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactory.java
index 8c9d473..15a648b 100644
--- 
a/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactory.java
+++ 
b/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactory.java
@@ -111,10 +111,10 @@ public class LocalCachingContextClassLoaderFactory 
implements ContextClassLoader
    * (if it changed).
    */
   private void monitorContext(final String contextLocation, long interval) {
-    EXECUTOR.schedule(() -> checkMonitoredLocation(contextLocation, interval), 
interval,
-        TimeUnit.SECONDS);
     LOG.trace("Monitoring context definition file {} for changes at {} second 
intervals",
         contextLocation, interval);
+    EXECUTOR.schedule(() -> checkMonitoredLocation(contextLocation, interval), 
interval,
+        TimeUnit.SECONDS);
   }
 
   // for tests only
diff --git 
a/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/definition/ContextDefinition.java
 
b/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/definition/ContextDefinition.java
index 83187de..356bde8 100644
--- 
a/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/definition/ContextDefinition.java
+++ 
b/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/definition/ContextDefinition.java
@@ -48,11 +48,6 @@ public class ContextDefinition {
 
   public static ContextDefinition create(int monitorIntervalSecs, URL... 
sources)
       throws IOException {
-    return create("unknown", monitorIntervalSecs, sources);
-  }
-
-  public static ContextDefinition create(String sourceFileName, int 
monitorIntervalSecs,
-      URL... sources) throws IOException {
     LinkedHashSet<Resource> resources = new LinkedHashSet<>();
     for (URL u : sources) {
       FileResolver resolver = FileResolver.resolve(u);
@@ -61,7 +56,7 @@ public class ContextDefinition {
         resources.add(new Resource(u, checksum));
       }
     }
-    return new ContextDefinition(sourceFileName, monitorIntervalSecs, 
resources);
+    return new ContextDefinition(monitorIntervalSecs, resources);
   }
 
   public static ContextDefinition fromRemoteURL(final URL url) throws 
IOException {
@@ -71,13 +66,11 @@ public class ContextDefinition {
       if (def == null) {
         throw new EOFException("InputStream does not contain a valid 
ContextDefinition at " + url);
       }
-      def.sourceFileName = resolver.getFileName();
       return def;
     }
   }
 
   // transient fields that don't go in the json
-  private transient String sourceFileName;
   private final transient Supplier<String> checksum =
       Suppliers.memoize(() -> DIGESTER.digestAsHex(toJson()));
 
@@ -88,20 +81,13 @@ public class ContextDefinition {
 
   public ContextDefinition() {}
 
-  public ContextDefinition(String sourceFileName, int monitorIntervalSeconds,
-      LinkedHashSet<Resource> resources) {
-    this.sourceFileName = requireNonNull(sourceFileName, "source file name 
must be supplied");
-
+  public ContextDefinition(int monitorIntervalSeconds, LinkedHashSet<Resource> 
resources) {
     Preconditions.checkArgument(monitorIntervalSeconds > 0,
         "monitor interval must be greater than zero");
     this.monitorIntervalSeconds = monitorIntervalSeconds;
     this.resources = requireNonNull(resources, "resources must be supplied");
   }
 
-  public String getSourceFileName() {
-    return sourceFileName;
-  }
-
   public int getMonitorIntervalSeconds() {
     return monitorIntervalSeconds;
   }
@@ -112,7 +98,7 @@ public class ContextDefinition {
 
   @Override
   public int hashCode() {
-    return hash(sourceFileName, monitorIntervalSeconds, resources);
+    return hash(monitorIntervalSeconds, resources);
   }
 
   @Override
@@ -127,8 +113,7 @@ public class ContextDefinition {
       return false;
     }
     ContextDefinition other = (ContextDefinition) obj;
-    return Objects.equals(sourceFileName, other.sourceFileName)
-        && monitorIntervalSeconds == other.monitorIntervalSeconds
+    return monitorIntervalSeconds == other.monitorIntervalSeconds
         && Objects.equals(resources, other.resources);
   }
 
diff --git 
a/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
 
b/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
index 4d819da..d8675ca 100644
--- 
a/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
+++ 
b/modules/local-caching-classloader/src/main/java/org/apache/accumulo/classloader/lcc/util/LocalStore.java
@@ -112,7 +112,7 @@ public final class LocalStore {
   // extension, and will instead just append the checksum to the original file 
name
   private static Pattern fileNamesWithExtensionPattern = 
Pattern.compile("^(.*[^.].*)[.]([^.]+)$");
 
-  static String localName(String remoteFileName, String checksum) {
+  static String localResourceName(String remoteFileName, String checksum) {
     requireNonNull(remoteFileName);
     requireNonNull(checksum);
     var matcher = fileNamesWithExtensionPattern.matcher(remoteFileName);
@@ -134,11 +134,7 @@ public final class LocalStore {
     requireNonNull(contextDefinition, "definition must be supplied");
     // use a LinkedHashSet to preserve the order of the context resources
     final Set<Path> localFiles = new LinkedHashSet<>();
-    // store it with a .json suffix, if the original file didn't have one
-    final String origSourceName = contextDefinition.getSourceFileName();
-    final String sourceNameWithSuffix =
-        origSourceName.toLowerCase().endsWith(".json") ? origSourceName : 
origSourceName + ".json";
-    final String destinationName = localName(sourceNameWithSuffix, 
contextDefinition.getChecksum());
+    final String destinationName = contextDefinition.getChecksum() + ".json";
     try {
       storeContextDefinition(contextDefinition, destinationName);
       boolean successful = false;
@@ -200,7 +196,7 @@ public final class LocalStore {
   private Path storeResource(final Resource resource) throws IOException {
     final URL url = resource.getLocation();
     final FileResolver source = FileResolver.resolve(url);
-    final String baseName = localName(source.getFileName(), 
resource.getChecksum());
+    final String baseName = localResourceName(source.getFileName(), 
resource.getChecksum());
     final Path destinationPath = resourcesDir.resolve(baseName);
     final Path tempPath = resourcesDir.resolve(tempName(baseName));
     final Path downloadingProgressPath = resourcesDir.resolve("." + baseName + 
".downloading");
@@ -250,7 +246,7 @@ public final class LocalStore {
           Files.write(downloadingProgressPath, PID.getBytes(UTF_8), 
TRUNCATE_EXISTING);
         } catch (IOException e) {
           LOG.warn(
-              "Error writing progress file {}. Other processes may attempt 
downloading the same file.",
+              "Error writing progress file {}. Other processes may attempt to 
download the same file concurrently.",
               downloadingProgressPath, e);
         }
         try {
diff --git 
a/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactoryTest.java
 
b/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactoryTest.java
index b5d5ceb..823ec6d 100644
--- 
a/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactoryTest.java
+++ 
b/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/LocalCachingContextClassLoaderFactoryTest.java
@@ -133,7 +133,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     final URL jarCJettyLocation = jetty.getURI().resolve("TestC.jar").toURL();
 
     // ContextDefinition with all jars
-    var allJarsDef = ContextDefinition.create("all", MONITOR_INTERVAL_SECS, 
jarAOrigLocation,
+    var allJarsDef = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation,
         jarBHdfsLocation, jarCJettyLocation, jarDOrigLocation);
     String allJarsDefJson = allJarsDef.toJson();
 
@@ -226,7 +226,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
   @Test
   public void testInitialInvalidJson() throws Exception {
     // Create a new context definition file in HDFS, but with invalid content
-    var def = ContextDefinition.create("invalid", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+    var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
     // write out invalid json
     final Path invalid = createContextDefinitionFile(fs, 
"InvalidContextDefinitionFile.json",
         def.toJson().substring(0, 4));
@@ -240,7 +240,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
 
   @Test
   public void testInitial() throws Exception {
-    var def = ContextDefinition.create("initial", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+    var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
     final Path initial =
         createContextDefinitionFile(fs, "InitialContextDefinitionFile.json", 
def.toJson());
     final URL initialDefUrl = new URL(fs.getUri().toString() + 
initial.toUri().toString());
@@ -264,7 +264,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     Files.copy(jarAPath, jarACopy, StandardCopyOption.REPLACE_EXISTING);
     assertTrue(Files.exists(jarACopy));
 
-    var def = ContextDefinition.create("initial", MONITOR_INTERVAL_SECS, 
jarACopy.toUri().toURL());
+    var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarACopy.toUri().toURL());
 
     Files.delete(jarACopy);
     assertTrue(!Files.exists(jarACopy));
@@ -284,7 +284,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     resources.add(new Resource(jarAOrigLocation, "1234"));
 
     // remove the file:// prefix from the URL
-    String goodJson = new ContextDefinition("initial", MONITOR_INTERVAL_SECS, 
resources).toJson();
+    String goodJson = new ContextDefinition(MONITOR_INTERVAL_SECS, 
resources).toJson();
     String badJson =
         goodJson.replace(jarAOrigLocation.toString(), 
jarAOrigLocation.toString().substring(6));
     assertNotEquals(goodJson, badJson);
@@ -309,7 +309,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     LinkedHashSet<Resource> resources = new LinkedHashSet<>();
     resources.add(r);
 
-    var def = new ContextDefinition("initial", MONITOR_INTERVAL_SECS, 
resources);
+    var def = new ContextDefinition(MONITOR_INTERVAL_SECS, resources);
 
     final Path initial = createContextDefinitionFile(fs,
         "InitialContextDefinitionBadResourceChecksum.json", def.toJson());
@@ -332,7 +332,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
 
   @Test
   public void testUpdate() throws Exception {
-    final var def = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+    final var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
     final Path defFilePath =
         createContextDefinitionFile(fs, "UpdateContextDefinitionFile.json", 
def.toJson());
     final URL updateDefUrl = new URL(fs.getUri().toString() + 
defFilePath.toUri().toString());
@@ -345,7 +345,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     testClassFailsToLoad(cl, classD);
 
     // Update the contents of the context definition json file
-    var updateDef = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarDOrigLocation);
+    var updateDef = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarDOrigLocation);
     updateContextDefinitionFile(fs, defFilePath, updateDef.toJson());
 
     // wait 2x the monitor interval
@@ -363,7 +363,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
 
   @Test
   public void testUpdateSameClassNameDifferentContent() throws Exception {
-    final var def = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+    final var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
     final Path defFilePath =
         createContextDefinitionFile(fs, "UpdateContextDefinitionFile.json", 
def.toJson());
     final URL updateDefUrl = new URL(fs.getUri().toString() + 
defFilePath.toUri().toString());
@@ -376,7 +376,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     testClassFailsToLoad(cl, classD);
 
     // Update the contents of the context definition json file
-    var updateDef = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarEOrigLocation);
+    var updateDef = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarEOrigLocation);
     updateContextDefinitionFile(fs, defFilePath, updateDef.toJson());
 
     // wait 2x the monitor interval
@@ -396,7 +396,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
 
   @Test
   public void testUpdateContextDefinitionEmpty() throws Exception {
-    final var def = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+    final var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
     final Path defFilePath =
         createContextDefinitionFile(fs, 
"UpdateEmptyContextDefinitionFile.json", def.toJson());
     final URL updateDefUrl = new URL(fs.getUri().toString() + 
defFilePath.toUri().toString());
@@ -427,7 +427,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
 
   @Test
   public void testUpdateNonExistentResource() throws Exception {
-    final var def = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+    final var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
     final Path defFilePath =
         createContextDefinitionFile(fs, "UpdateNonExistentResource.json", 
def.toJson());
     final URL updateDefUrl = new URL(fs.getUri().toString() + 
defFilePath.toUri().toString());
@@ -449,7 +449,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     assertTrue(!Files.exists(jarACopy));
     Files.copy(jarAPath, jarACopy, StandardCopyOption.REPLACE_EXISTING);
     assertTrue(Files.exists(jarACopy));
-    var def2 = ContextDefinition.create("initial", MONITOR_INTERVAL_SECS, 
jarACopy.toUri().toURL());
+    var def2 = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarACopy.toUri().toURL());
     Files.delete(jarACopy);
     assertTrue(!Files.exists(jarACopy));
 
@@ -470,7 +470,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
 
   @Test
   public void testUpdateBadResourceChecksum() throws Exception {
-    final var def = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+    final var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
     final Path defFilePath =
         createContextDefinitionFile(fs, "UpdateBadResourceChecksum.json", 
def.toJson());
     final URL updateDefUrl = new URL(fs.getUri().toString() + 
defFilePath.toUri().toString());
@@ -486,7 +486,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     LinkedHashSet<Resource> resources = new LinkedHashSet<>();
     resources.add(r);
 
-    var def2 = new ContextDefinition("update", MONITOR_INTERVAL_SECS, 
resources);
+    var def2 = new ContextDefinition(MONITOR_INTERVAL_SECS, resources);
 
     updateContextDefinitionFile(fs, defFilePath, def2.toJson());
 
@@ -505,7 +505,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
 
   @Test
   public void testUpdateBadResourceURL() throws Exception {
-    final var def = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+    final var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
     final Path defFilePath =
         createContextDefinitionFile(fs, "UpdateBadResourceChecksum.json", 
def.toJson());
     final URL updateDefUrl = new URL(fs.getUri().toString() + 
defFilePath.toUri().toString());
@@ -520,7 +520,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     // remove the file:// prefix from the URL
     LinkedHashSet<Resource> resources = new LinkedHashSet<>();
     resources.add(new Resource(jarAOrigLocation, "1234"));
-    String goodJson = new ContextDefinition("initial", MONITOR_INTERVAL_SECS, 
resources).toJson();
+    String goodJson = new ContextDefinition(MONITOR_INTERVAL_SECS, 
resources).toJson();
     String badJson =
         goodJson.replace(jarAOrigLocation.toString(), 
jarAOrigLocation.toString().substring(6));
     assertNotEquals(goodJson, badJson);
@@ -542,7 +542,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
 
   @Test
   public void testUpdateInvalidJson() throws Exception {
-    final var def = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+    final var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
     final Path defFilePath =
         createContextDefinitionFile(fs, 
"UpdateInvalidContextDefinitionFile.json", def.toJson());
     final URL updateDefUrl = new URL(fs.getUri().toString() + 
defFilePath.toUri().toString());
@@ -554,7 +554,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     testClassFailsToLoad(cl, classC);
     testClassFailsToLoad(cl, classD);
 
-    var updateDef = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarDOrigLocation);
+    var updateDef = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarDOrigLocation);
     updateContextDefinitionFile(fs, defFilePath, 
updateDef.toJson().substring(0, 4));
 
     // wait 2x the monitor interval
@@ -587,8 +587,8 @@ public class LocalCachingContextClassLoaderFactoryTest {
 
   @Test
   public void testChangingContext() throws Exception {
-    var def = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarAOrigLocation,
-        jarBOrigLocation, jarCOrigLocation, jarDOrigLocation);
+    var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation, jarBOrigLocation,
+        jarCOrigLocation, jarDOrigLocation);
     final Path update =
         createContextDefinitionFile(fs, 
"UpdateChangingContextDefinition.json", def.toJson());
     final URL updatedDefUrl = new URL(fs.getUri().toString() + 
update.toUri().toString());
@@ -614,8 +614,8 @@ public class LocalCachingContextClassLoaderFactoryTest {
       final URL removed = updatedList.remove(0);
 
       // Update the contents of the context definition json file
-      var updateDef = ContextDefinition.create("update", MONITOR_INTERVAL_SECS,
-          updatedList.toArray(new URL[] {}));
+      var updateDef =
+          ContextDefinition.create(MONITOR_INTERVAL_SECS, 
updatedList.toArray(new URL[0]));
       updateContextDefinitionFile(fs, update, updateDef.toJson());
 
       // wait 2x the monitor interval
@@ -667,7 +667,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
         Map.of(CACHE_DIR_PROPERTY, baseCacheDir, 
UPDATE_FAILURE_GRACE_PERIOD_MINS, "1"));
     localFactory.init(() -> new ConfigurationImpl(acuConf));
 
-    final var def = ContextDefinition.create("update", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+    final var def = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
     final Path defFilePath =
         createContextDefinitionFile(fs, "UpdateNonExistentResource.json", 
def.toJson());
     final URL updateDefUrl = new URL(fs.getUri().toString() + 
defFilePath.toUri().toString());
@@ -689,7 +689,7 @@ public class LocalCachingContextClassLoaderFactoryTest {
     assertTrue(!Files.exists(jarACopy));
     Files.copy(jarAPath, jarACopy, StandardCopyOption.REPLACE_EXISTING);
     assertTrue(Files.exists(jarACopy));
-    var def2 = ContextDefinition.create("initial", MONITOR_INTERVAL_SECS, 
jarACopy.toUri().toURL());
+    var def2 = ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarACopy.toUri().toURL());
     Files.delete(jarACopy);
     assertTrue(!Files.exists(jarACopy));
 
diff --git 
a/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/MiniAccumuloClusterClassLoaderFactoryTest.java
 
b/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/MiniAccumuloClusterClassLoaderFactoryTest.java
index 692f395..39a7436 100644
--- 
a/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/MiniAccumuloClusterClassLoaderFactoryTest.java
+++ 
b/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/MiniAccumuloClusterClassLoaderFactoryTest.java
@@ -137,7 +137,7 @@ public class MiniAccumuloClusterClassLoaderFactoryTest 
extends SharedMiniCluster
 
     // Create a context definition that only references jar A
     final ContextDefinition testContextDef =
-        ContextDefinition.create("test", MONITOR_INTERVAL_SECS, 
jarAOrigLocation);
+        ContextDefinition.create(MONITOR_INTERVAL_SECS, jarAOrigLocation);
     final String testContextDefJson = testContextDef.toJson();
     final File testContextDefFile = 
jsonDirPath.resolve("testContextDefinition.json").toFile();
     Files.writeString(testContextDefFile.toPath(), testContextDefJson, 
StandardOpenOption.CREATE);
@@ -212,7 +212,7 @@ public class MiniAccumuloClusterClassLoaderFactoryTest 
extends SharedMiniCluster
 
       // Update the context definition to point to jar B
       final ContextDefinition testContextDefUpdate =
-          ContextDefinition.create("test", MONITOR_INTERVAL_SECS, 
jarBOrigLocation);
+          ContextDefinition.create(MONITOR_INTERVAL_SECS, jarBOrigLocation);
       final String testContextDefUpdateJson = testContextDefUpdate.toJson();
       Files.writeString(testContextDefFile.toPath(), testContextDefUpdateJson,
           StandardOpenOption.TRUNCATE_EXISTING);
@@ -239,7 +239,7 @@ public class MiniAccumuloClusterClassLoaderFactoryTest 
extends SharedMiniCluster
       assertTrue(Files.exists(jarACopy));
 
       final ContextDefinition testContextDefUpdate2 =
-          ContextDefinition.create("test", MONITOR_INTERVAL_SECS, 
jarACopy.toUri().toURL());
+          ContextDefinition.create(MONITOR_INTERVAL_SECS, 
jarACopy.toUri().toURL());
       Files.delete(jarACopy);
       assertTrue(!Files.exists(jarACopy));
 
diff --git 
a/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/util/LocalStoreTest.java
 
b/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/util/LocalStoreTest.java
index dc86429..a4c50d8 100644
--- 
a/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/util/LocalStoreTest.java
+++ 
b/modules/local-caching-classloader/src/test/java/org/apache/accumulo/classloader/lcc/util/LocalStoreTest.java
@@ -54,7 +54,6 @@ public class LocalStoreTest {
   @TempDir
   private static java.nio.file.Path tempDir;
 
-  private static final String CONTEXT_NAME = "TEST_CONTEXT";
   private static final int MONITOR_INTERVAL_SECS = 5;
   private static MiniDFSCluster hdfs;
   private static Server jetty;
@@ -102,7 +101,7 @@ public class LocalStoreTest {
     resources
         .add(new Resource(jarCNewLocation, 
TestUtils.computeResourceChecksum(jarCOrigLocation)));
 
-    def = new ContextDefinition(CONTEXT_NAME, MONITOR_INTERVAL_SECS, 
resources);
+    def = new ContextDefinition(MONITOR_INTERVAL_SECS, resources);
     classA = new TestClassInfo("test.TestObjectA", "Hello from A");
     classB = new TestClassInfo("test.TestObjectB", "Hello from B");
     classC = new TestClassInfo("test.TestObjectC", "Hello from C");
@@ -158,31 +157,31 @@ public class LocalStoreTest {
 
   @Test
   public void testLocalFileName() {
-    // regular json
-    assertEquals("f1-chk1.json", LocalStore.localName("f1.json", "chk1"));
-    // dotfile json
-    assertEquals(".f1-chk1.json", LocalStore.localName(".f1.json", "chk1"));
+    // regular war
+    assertEquals("f1-chk1.war", LocalStore.localResourceName("f1.war", 
"chk1"));
+    // dotfile war
+    assertEquals(".f1-chk1.war", LocalStore.localResourceName(".f1.war", 
"chk1"));
     // regular jar (has multiple dots)
-    assertEquals("f2-1.0-chk2.jar", LocalStore.localName("f2-1.0.jar", 
"chk2"));
+    assertEquals("f2-1.0-chk2.jar", LocalStore.localResourceName("f2-1.0.jar", 
"chk2"));
     // dotfile jar (has multiple dots)
-    assertEquals(".f2-1.0-chk2.jar", LocalStore.localName(".f2-1.0.jar", 
"chk2"));
+    assertEquals(".f2-1.0-chk2.jar", 
LocalStore.localResourceName(".f2-1.0.jar", "chk2"));
     // regular file with no suffix
-    assertEquals("f3-chk3", LocalStore.localName("f3", "chk3"));
+    assertEquals("f3-chk3", LocalStore.localResourceName("f3", "chk3"));
 
     // weird files with trailing dots and no file suffix
-    assertEquals("f4.-chk4", LocalStore.localName("f4.", "chk4"));
-    assertEquals("f4..-chk4", LocalStore.localName("f4..", "chk4"));
-    assertEquals("f4...-chk4", LocalStore.localName("f4...", "chk4"));
+    assertEquals("f4.-chk4", LocalStore.localResourceName("f4.", "chk4"));
+    assertEquals("f4..-chk4", LocalStore.localResourceName("f4..", "chk4"));
+    assertEquals("f4...-chk4", LocalStore.localResourceName("f4...", "chk4"));
     // weird dotfiles that don't really have a suffix
-    assertEquals(".f5-chk5", LocalStore.localName(".f5", "chk5"));
-    assertEquals("..f5-chk5", LocalStore.localName("..f5", "chk5"));
+    assertEquals(".f5-chk5", LocalStore.localResourceName(".f5", "chk5"));
+    assertEquals("..f5-chk5", LocalStore.localResourceName("..f5", "chk5"));
     // weird files with weird dots, but do have a valid suffix
-    assertEquals("f6.-chk6.jar", LocalStore.localName("f6..jar", "chk6"));
-    assertEquals("f6..-chk6.jar", LocalStore.localName("f6...jar", "chk6"));
-    assertEquals(".f6-chk6.jar", LocalStore.localName(".f6.jar", "chk6"));
-    assertEquals("..f6-chk6.jar", LocalStore.localName("..f6.jar", "chk6"));
-    assertEquals(".f6.-chk6.jar", LocalStore.localName(".f6..jar", "chk6"));
-    assertEquals("..f6.-chk6.jar", LocalStore.localName("..f6..jar", "chk6"));
+    assertEquals("f6.-chk6.jar", LocalStore.localResourceName("f6..jar", 
"chk6"));
+    assertEquals("f6..-chk6.jar", LocalStore.localResourceName("f6...jar", 
"chk6"));
+    assertEquals(".f6-chk6.jar", LocalStore.localResourceName(".f6.jar", 
"chk6"));
+    assertEquals("..f6-chk6.jar", LocalStore.localResourceName("..f6.jar", 
"chk6"));
+    assertEquals(".f6.-chk6.jar", LocalStore.localResourceName(".f6..jar", 
"chk6"));
+    assertEquals("..f6.-chk6.jar", LocalStore.localResourceName("..f6..jar", 
"chk6"));
   }
 
   @Test
@@ -192,13 +191,12 @@ public class LocalStoreTest {
 
     // Confirm the 3 jars are cached locally
     assertTrue(Files.exists(baseCacheDir));
-    assertTrue(Files.exists(baseCacheDir.resolve("contexts")
-        .resolve(CONTEXT_NAME + "-" + def.getChecksum() + ".json")));
+    
assertTrue(Files.exists(baseCacheDir.resolve("contexts").resolve(def.getChecksum()
 + ".json")));
     for (Resource r : def.getResources()) {
       String filename = TestUtils.getFileName(r.getLocation());
       String checksum = r.getChecksum();
-      assertTrue(Files.exists(
-          
baseCacheDir.resolve("resources").resolve(LocalStore.localName(filename, 
checksum))));
+      assertTrue(Files.exists(baseCacheDir.resolve("resources")
+          .resolve(LocalStore.localResourceName(filename, checksum))));
     }
   }
 
@@ -234,24 +232,24 @@ public class LocalStoreTest {
     updatedResources
         .add(new Resource(jarDOrigLocation, 
TestUtils.computeResourceChecksum(jarDOrigLocation)));
 
-    var updatedDef = new ContextDefinition(CONTEXT_NAME, 
MONITOR_INTERVAL_SECS, updatedResources);
+    var updatedDef = new ContextDefinition(MONITOR_INTERVAL_SECS, 
updatedResources);
     urls = localStore.storeContextResources(updatedDef);
 
     // Confirm the 3 jars are cached locally
-    assertTrue(Files.exists(baseCacheDir.resolve("contexts")
-        .resolve(CONTEXT_NAME + "-" + updatedDef.getChecksum() + ".json")));
+    assertTrue(
+        
Files.exists(baseCacheDir.resolve("contexts").resolve(updatedDef.getChecksum() 
+ ".json")));
     for (Resource r : updatedDef.getResources()) {
       String filename = TestUtils.getFileName(r.getLocation());
       assertFalse(filename.contains("C"));
       String checksum = r.getChecksum();
-      assertTrue(Files.exists(
-          
baseCacheDir.resolve("resources").resolve(LocalStore.localName(filename, 
checksum))));
+      assertTrue(Files.exists(baseCacheDir.resolve("resources")
+          .resolve(LocalStore.localResourceName(filename, checksum))));
     }
 
     String filename = TestUtils.getFileName(removedResource.getLocation());
     assertTrue(filename.contains("C"), "cache location should still contain 
'C'");
     assertTrue(Files.exists(baseCacheDir.resolve("resources")
-        .resolve(LocalStore.localName(filename, 
removedResource.getChecksum()))));
+        .resolve(LocalStore.localResourceName(filename, 
removedResource.getChecksum()))));
 
     final var updatedContextClassLoader = LccUtils.createClassLoader("url", 
urls);
 

Reply via email to