Skip to content

Commit

Permalink
Use ContextClassLoader when loading a class
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jun 18, 2020
1 parent 002dc3f commit db3ff72
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion java/server/src/org/openqa/selenium/grid/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Logger;

public interface Config {

Expand All @@ -46,8 +47,13 @@ default Optional<Boolean> getBool(String section, String option) {
default <X> X getClass(String section, String option, Class<X> typeOfClass, String defaultClazz) {
String clazz = get(section, option).orElse(defaultClazz);

// We don't declare a constant on the interface, natch.
Logger.getLogger(Config.class.getName()).fine(String.format("Creating %s as instance of %s", clazz, typeOfClass));

try {
Class<?> ClassClazz = Class.forName(clazz);
// Use the context class loader since this is what the `--ext`
// flag modifies.
Class<?> ClassClazz = Class.forName(clazz, true, Thread.currentThread().getContextClassLoader());
Method create = ClassClazz.getMethod("create", Config.class);

if (!Modifier.isStatic(create.getModifiers())) {
Expand Down

0 comments on commit db3ff72

Please sign in to comment.