rfscholte commented on code in PR #13845:
URL: https://github.com/apache/pinot/pull/13845#discussion_r1721773871


##########
pinot-spi/src/main/java/org/apache/pinot/spi/plugin/PluginManager.java:
##########
@@ -111,13 +123,31 @@ public class PluginManager {
         }
       };
 
-  private Map<Plugin, PluginClassLoader> _registry = new HashMap<>();
+  private final ClassWorld classWorld;
+  private final Map<Plugin, PluginClassLoader> _registry;
+
   private String _pluginsDirectories;
   private String _pluginsInclude;
   private boolean _initialized = false;
 
   private PluginManager() {
-    _registry.put(new Plugin(DEFAULT_PLUGIN_NAME), 
createClassLoader(Collections.emptyList()));
+    if(useLegacyPluginClassloader()) {
+      _registry = new HashMap<>();
+      _registry.put(new Plugin(DEFAULT_PLUGIN_NAME), 
createClassLoader(Collections.emptyList()));
+      classWorld = null;
+    }
+    else {
+      try {
+        this.classWorld = new ClassWorld();
+        // to simulate behavior of legacy code, however every plugin should 
have a dedicated realm
+        this.classWorld.newRealm(DEFAULT_PLUGIN_NAME);
+        this.classWorld.newRealm("pinot", ClassLoader.getSystemClassLoader());
+        this._registry = null;
+      } catch (DuplicateRealmException e) {
+        throw new RuntimeException(e);

Review Comment:
   That's correct. Classworld starts like an empty map, but adding a realm 
comes with a checked exception



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to