Skip to content

Commit 51ef290

Browse files
authored
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]>
1 parent 0cf2f0e commit 51ef290

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/PluginClassLoader.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
import java.io.IOException;
2323
import java.net.URL;
2424
import java.net.URLClassLoader;
25+
import java.util.ArrayList;
26+
import java.util.Collections;
2527
import java.util.Enumeration;
28+
import java.util.List;
2629
import java.util.Objects;
27-
import java.util.Vector;
2830

2931
/**
3032
* A custom classloader dedicated to loading Connect plugin classes in classloading isolation.
@@ -87,7 +89,7 @@ public URL getResource(String name) {
8789
@Override
8890
public Enumeration<URL> getResources(String name) throws IOException {
8991
Objects.requireNonNull(name);
90-
Vector<URL> resources = new Vector<>();
92+
List<URL> resources = new ArrayList<>();
9193
for (Enumeration<URL> foundLocally = findResources(name); foundLocally.hasMoreElements();) {
9294
URL url = foundLocally.nextElement();
9395
if (url != null)
@@ -99,7 +101,7 @@ public Enumeration<URL> getResources(String name) throws IOException {
99101
if (url != null)
100102
resources.add(url);
101103
}
102-
return resources.elements();
104+
return Collections.enumeration(resources);
103105
}
104106

105107
// This method needs to be thread-safe because it is supposed to be called by multiple

0 commit comments

Comments
 (0)