chia7712 commented on code in PR #22547:
URL: https://github.com/apache/kafka/pull/22547#discussion_r3408695728
##########
connect/runtime/src/testFixtures/java/org/apache/kafka/connect/runtime/isolation/TestPlugins.java:
##########
@@ -417,6 +429,31 @@ private static Path resourceDirectoryPath(String
resourceDir) throws IOException
return file;
}
+ private static Path extractResourceDirectoryFromJar(String resourceDir,
URL resource) throws IOException {
+ String prefix = resourceDir.endsWith("/") ? resourceDir : resourceDir
+ "/";
+ Path tmpDir =
TestUtils.tempDirectory("test-plugins-resources.").toPath();
+ JarURLConnection connection = (JarURLConnection)
resource.openConnection();
+ // Do not share the cached JarFile with the classloader, so we own it
and can close it.
+ connection.setUseCaches(false);
+ try (JarFile jarFile = connection.getJarFile()) {
+ Enumeration<JarEntry> entries = jarFile.entries();
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+ String name = entry.getName();
+ if (entry.isDirectory() || !name.startsWith(prefix)) {
+ continue;
+ }
+ Path dest = tmpDir.resolve(name.substring(prefix.length()));
+ Files.createDirectories(dest.getParent());
+ try (InputStream in = jarFile.getInputStream(entry)) {
+ Files.copy(in, dest, StandardCopyOption.REPLACE_EXISTING);
+ }
+ dest.toFile().deleteOnExit();
Review Comment:
this is unnecessary now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]