mirror of https://github.com/apache/kafka.git
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 <payang@apache.org>, Ken Huang <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
0cf2f0e55d
commit
51ef2903f7
|
@ -22,9 +22,11 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A custom classloader dedicated to loading Connect plugin classes in classloading isolation.
|
* A custom classloader dedicated to loading Connect plugin classes in classloading isolation.
|
||||||
|
@ -87,7 +89,7 @@ public class PluginClassLoader extends URLClassLoader {
|
||||||
@Override
|
@Override
|
||||||
public Enumeration<URL> getResources(String name) throws IOException {
|
public Enumeration<URL> getResources(String name) throws IOException {
|
||||||
Objects.requireNonNull(name);
|
Objects.requireNonNull(name);
|
||||||
Vector<URL> resources = new Vector<>();
|
List<URL> resources = new ArrayList<>();
|
||||||
for (Enumeration<URL> foundLocally = findResources(name); foundLocally.hasMoreElements();) {
|
for (Enumeration<URL> foundLocally = findResources(name); foundLocally.hasMoreElements();) {
|
||||||
URL url = foundLocally.nextElement();
|
URL url = foundLocally.nextElement();
|
||||||
if (url != null)
|
if (url != null)
|
||||||
|
@ -99,7 +101,7 @@ public class PluginClassLoader extends URLClassLoader {
|
||||||
if (url != null)
|
if (url != null)
|
||||||
resources.add(url);
|
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
|
// This method needs to be thread-safe because it is supposed to be called by multiple
|
||||||
|
|
Loading…
Reference in New Issue