This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 51ef2903f76 KAFKA-19178 Replace Vector by ArrayList for
PluginClassLoader#getResources (#19529)
51ef2903f76 is described below
commit 51ef2903f76b3ac7ac44bbf51a1f318f536fdd6c
Author: Nick Guo <[email protected]>
AuthorDate: Sat Apr 26 23:39:02 2025 +0800
KAFKA-19178 Replace Vector by ArrayList for PluginClassLoader#getResources
(#19529)
The vector is a synchronized collection, and in the case we don't need
to sync. Also, we can use `Collections.enumeration` to convert
collection to enumeration easily.
Reviewers: PoAn Yang <[email protected]>, Ken Huang
<[email protected]>, Chia-Ping Tsai <[email protected]>
---
.../apache/kafka/connect/runtime/isolation/PluginClassLoader.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git
a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginClassLoader.java
b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginClassLoader.java
index 693972c1989..d1829b731dc 100644
---
a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginClassLoader.java
+++
b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginClassLoader.java
@@ -22,9 +22,11 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.List;
import java.util.Objects;
-import java.util.Vector;
/**
* A custom classloader dedicated to loading Connect plugin classes in
classloading isolation.
@@ -87,7 +89,7 @@ public class PluginClassLoader extends URLClassLoader {
@Override
public Enumeration<URL> getResources(String name) throws IOException {
Objects.requireNonNull(name);
- Vector<URL> resources = new Vector<>();
+ List<URL> resources = new ArrayList<>();
for (Enumeration<URL> foundLocally = findResources(name);
foundLocally.hasMoreElements();) {
URL url = foundLocally.nextElement();
if (url != null)
@@ -99,7 +101,7 @@ public class PluginClassLoader extends URLClassLoader {
if (url != null)
resources.add(url);
}
- return resources.elements();
+ return Collections.enumeration(resources);
}
// This method needs to be thread-safe because it is supposed to be called
by multiple