aymkhalil opened a new issue, #20061:
URL: https://github.com/apache/pulsar/issues/20061

   ### Search before asking
   
   - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) 
and found nothing similar.
   
   
   ### Motivation
   
   Pulsar-shell would attempt to load the NAR files every time a new 
custom/extention command is invoked (see 
[PIP-201](https://github.com/apache/pulsar/issues/17155) for context regarding 
Pulsar Admin CLI Extensions). 
   
   This works fine with caveats:
   * Multiple NAR loading seems redundant. It is fair to expect the user to 
restart the shell session if the underlying NAR is updated.
   * It has some interesting consequences when the the extensions command has a 
runtime dependency on a class that is available on the parent class loader.
   
   For example, I ran into a scenario where the extension/custom command has a 
dependency on `netty-common` - the command would load on the NAR class loader, 
but the netty dependency will load on the parent class loader (the admin's 
AppClassLoader). Between shell commands invocations, the classes in the NAR 
class loader are recycled, but the netty classes are not. This lead to any 
"static" state to appear as "leaking" when the CLI is invoked for the second 
time.
   
   ### Solution
   
   Implementing "singleton" custom command bootstrapping (the NAR class loader 
and other necessary initialization) would do, at least in theory. 
   
   
   
   ### Alternatives
   
   Switch the order by which class loader work (child then parent) although 
this seems unnecessarily complex. 
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [X] I'm willing to submit a PR!


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to