This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new e991658dc3 Force driver load to avoid deadlocks, fixes #5698 (#7829)
e991658dc3 is described below

commit e991658dc37a11087998f6eb97602f13ccd4afc3
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Fri Aug 7 13:59:46 2026 +0200

    Force driver load to avoid deadlocks, fixes #5698 (#7829)
---
 .../src/main/java/org/apache/hop/core/database/Database.java | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/core/src/main/java/org/apache/hop/core/database/Database.java 
b/core/src/main/java/org/apache/hop/core/database/Database.java
index 0a5d73babd..b64ddc6b05 100644
--- a/core/src/main/java/org/apache/hop/core/database/Database.java
+++ b/core/src/main/java/org/apache/hop/core/database/Database.java
@@ -436,6 +436,18 @@ public class Database implements IVariables, 
ILoggingObject, AutoCloseable {
 
     try {
       synchronized (DriverManager.class) {
+        // Force the JDBC 4 driver ServiceLoader scan to run here, while we 
hold the lock.
+        //
+        // DriverManager only performs that scan once, lazily, the first time 
a connection is
+        // opened. It instantiates every java.sql.Driver on the classpath, not 
just the one we
+        // need. If that happens in DriverManager.getConnection() below, it 
runs unsynchronized
+        // with the driver class loading of another transform's init thread: 
both threads then
+        // initialize the same driver class hierarchy from opposite ends and 
deadlock on the
+        // class initialization monitors, hanging the pipeline. Doing it here 
makes the scan
+        // happen exactly once, single threaded, before any driver class can 
be initialized by
+        // another route.
+        DriverManager.getDrivers();
+
         ClassLoader classLoader = 
PluginRegistry.getInstance().getClassLoader(plugin);
         Class<?> driverClass = classLoader.loadClass(classname);
 

Reply via email to