turcsanyip commented on PR #10670:
URL: https://github.com/apache/nifi/pull/10670#issuecomment-3696855856

   > Did a bit more digging on the Postgresql JDBC side to see if the Hikari 
approach could be used and it does look like Hikari is expecting the driver to 
still be registered as the list only considers registered drivers. The 
registration is happening at classload as @turcsanyip mentioned is the common 
case [1]. So I think this PR can be taken as is. There is a argument that the 
explicit register call in the DBCPConnectionService class could be removed but 
I think there could be an argument to leave it for "legacy" drivers. This does 
however raise that since this is happening within the Driver itself a second 
issue to review the HikariCPConnectionPool for the same issue is appropriate. I 
do not see any calls within the Hikari library to manage the deregister so it 
is very likely that the reference would remain in the DriverManager without an 
explicit call.
   > 
   > [1] 
https://github.com/pgjdbc/pgjdbc/blob/3609468d1422de2bb5ea989db4c9de706bb1c4ed/pgjdbc/src/main/java/org/postgresql/Driver.java#L76
   
   
   @bobpaulin Apologies for my late reply. Yes, the point is that the 
registration happens at class load time, whether it is triggered by Java’s 
Service Loader mechanism or in some other way. Thanks for clarifying it. My 
comment was a bit misleading because I focused on the service loader instead of 
the static initializer block you linked.
   
   So the code change works for "legacy" drivers (if any exist) but I still 
don't understand how it can improve the standard PostgreSQL driver as the new 
code never runs in this case. I also debugged the code and the registered 
drivers are still being accumulated in `DriverManager`. We may need something 
similar as in the Hikari PR where 
[registeredDriver](https://github.com/bobpaulin/nifi/blob/2a63a870d85958f5c693597aa8a7e0e297db2569/nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-hikari-dbcp-service/src/main/java/org/apache/nifi/dbcp/HikariCPConnectionPool.java#L549)
 reference is stored in the self-registered case as well. What do you think?


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