Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #5236] fix ServiceProvider loading class #5237

Merged
merged 2 commits into from
Oct 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,22 @@ protected static InputStream getResourceAsStream(ClassLoader loader, String name

public static <T> List<T> load(String name, Class<?> clazz) {
LOG.info("Looking for a resource file of name [{}] ...", name);
List<T> services = new ArrayList<T>();
List<T> services = new ArrayList<>();
try {
ArrayList<String> names = new ArrayList<String>();
final InputStream is = getResourceAsStream(getContextClassLoader(), name);
if (is != null) {
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
String serviceName = reader.readLine();
List<String> names = new ArrayList<>();
while (serviceName != null && !"".equals(serviceName)) {
LOG.info(
"Creating an instance as specified by file {} which was present in the path of the context classloader.",
name);
if (!names.contains(serviceName)) {
names.add(serviceName);
services.add(initService(getContextClassLoader(), serviceName, clazz));
}

services.add((T) initService(getContextClassLoader(), serviceName, clazz));

serviceName = reader.readLine();
}
reader.close();
Expand Down