Skip to content

Commit

Permalink
Don't load drivers through the service loader
Browse files Browse the repository at this point in the history
This was introduced in quarkusio#7089,
which was specifically about a bug when using opentracing,
which no longer has an extension in core,
and even its Quarkiverse extension is no longer maintained:
https://github.com/quarkiverse/quarkus-smallrye-opentracing

The service loading is also causing problems with quarkusio#41995

So, let's not do it all, assuming tests passes.
  • Loading branch information
yrodiere committed Jan 13, 2025
1 parent c672a0f commit 7c2ccdf
Showing 1 changed file with 0 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package io.quarkus.agroal.runtime;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.Statement;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -157,9 +154,6 @@ public AgroalDataSource createDataSource(String dataSourceName) {
"Datasource " + dataSourceName + " does not have a JDBC URL and should not be created");
}

// we first make sure that all available JDBC drivers are loaded in the current TCCL
loadDriversInTCCL();

AgroalDataSourceSupport.Entry matchingSupportEntry = agroalDataSourceSupport.entries.get(dataSourceName);
String resolvedDriverClass = matchingSupportEntry.resolvedDriverClass;
Class<?> driver;
Expand Down Expand Up @@ -354,21 +348,4 @@ public boolean isValid(Connection connection) {
poolConfiguration.flushOnClose(dataSourceJdbcRuntimeConfig.flushOnClose());
}

/**
* Uses the {@link ServiceLoader#load(Class) ServiceLoader to load the JDBC drivers} in context
* of the current {@link Thread#getContextClassLoader() TCCL}
*/
private static void loadDriversInTCCL() {
// load JDBC drivers in the current TCCL
final ServiceLoader<Driver> drivers = ServiceLoader.load(Driver.class);
final Iterator<Driver> iterator = drivers.iterator();
while (iterator.hasNext()) {
try {
// load the driver
iterator.next();
} catch (Throwable t) {
// ignore
}
}
}
}

0 comments on commit 7c2ccdf

Please sign in to comment.