Skip to content

Commit

Permalink
MINOR: Remove 'disable caching' workaround for Java 8 in connect (#18823
Browse files Browse the repository at this point in the history
)

Reviewers: Chia-Ping Tsai <[email protected]>, Greg Harris <[email protected]>
  • Loading branch information
ijuma authored Feb 6, 2025
1 parent 0621c0b commit da166b9
Showing 1 changed file with 0 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,12 @@ private static PluginLocation setupLocation(Path path, PluginLocationType type,
outputJar.getParent().toFile().mkdirs();
Files.copy(jarPath, outputJar, StandardCopyOption.REPLACE_EXISTING);
outputJar.toUri().toURL().openConnection().setDefaultUseCaches(false);
disableCaching(outputJar);
return new PluginLocation(outputJar);
}
case MULTI_JAR: {
Path outputJar = path.resolve(jarPath.getFileName());
outputJar.getParent().toFile().mkdirs();
Files.copy(jarPath, outputJar, StandardCopyOption.REPLACE_EXISTING);
disableCaching(outputJar);
return new PluginLocation(path);
}
default:
Expand All @@ -507,15 +505,6 @@ private static PluginLocation setupLocation(Path path, PluginLocationType type,
}
}

private static void disableCaching(Path path) throws IOException {
// This function is a workaround for a Java 8 caching bug. When Java 8 support is dropped it may be removed.
// This test runs the sync-manifests command, and _without stopping the jvm_ executes a list command.
// Under normal use, the sync-manifests command is followed immediately by a JVM shutdown, clearing caches.
// The Java 8 ServiceLoader does not disable the URLConnection caching, so doesn't read some previous writes.
// Java 9+ ServiceLoaders disable the URLConnection caching, so don't need this patch (it becomes a no-op)
path.toUri().toURL().openConnection().setDefaultUseCaches(false);
}

private static class PluginPathElement {
private final Path root;
private final List<PluginLocation> locations;
Expand Down

0 comments on commit da166b9

Please sign in to comment.