GitHub user lhotari added a comment to the discussion: Differences Between 
Packaging IO Connectors and Functions in .jar vs .nar

A nar file contains the dependent libraries in the file in 
META-INF/bundled-dependencies directory. Pulsar extracts the Nar file to a 
temporary directory using 
[NarUnpacker](https://github.com/apache/pulsar/blob/master/pulsar-common/src/main/java/org/apache/pulsar/common/nar/NarUnpacker.java)
 and uses 
[NarClassLoader](https://github.com/apache/pulsar/blob/master/pulsar-common/src/main/java/org/apache/pulsar/common/nar/NarClassLoader.java)
 to add all of the jar files in META-INF/bundled-dependencies to the 
classloader used to load a IO connector or function.

The alternative to a nar file would be to use a fat jar where all dependencies 
are combined in a single jar file.

The nar file doesn't provide classloader isolation from the parent classloader 
used in Pulsar. It's not possible to override a class that is available in the 
parent classloader when using Nar files. This could impact the behavior in some 
cases since there are multiple ways in Pulsar how Pulsar IO connectors or 
functions can be run.

One possible way to workaround that is to use a shaded jar instead of a nar 
file where all dependencies are relocated to a different package.

GitHub link: 
https://github.com/apache/pulsar/discussions/22711#discussioncomment-9443493

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to