bobpaulin commented on code in PR #10693:
URL: https://github.com/apache/nifi/pull/10693#discussion_r2651984120


##########
nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/dbcp/DBCPConnectionPool.java:
##########
@@ -262,14 +262,21 @@ protected Driver getDriver(final String driverName, final 
String url) {
         }
 
         try {
-            return DriverManager.getDriver(url);
+            final Driver driver = DriverManager.getDriver(url);
+            // Ensure drivers that register themselves during class loading 
can be set as the registeredDriver.
+            // This ensures drivers that register themselves can be 
deregisterd when the componet is removed.
+            // These drivers should be loaded in the same InstanceClassloader 
that load this component
+            if (driver != registeredDriver
+                    && 
driver.getClass().getClassLoader().equals(getClass().getClassLoader())) {

Review Comment:
   I do agree it's an anti-pattern.  This could also surface if a driver got 
transitively pulled into the NarClassLoader.  Perhaps a warning at least if we 
deregister and the classloaders are NOT equal might be more appropriate. Having 
a driver in the parent classloader would essentially ignore the driver 
specified for the parent rather than throwing an error.  While I understand 
it's viewed as low probability I also expect the cost of checking is equally 
low.



-- 
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