Skip to content

Commit 8dfd169

Browse files
committed
[#1565] Add check mark in front of the selected driver
1 parent 9cf94ce commit 8dfd169

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/logging/impl/Log.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public interface Log extends BasicLogger {
4747
void sqlClientUrl(String url);
4848

4949
@LogMessage(level = INFO)
50-
@Message(id = 13, value = "Detected driver [%1$s]")
51-
void detectedDriver(String driverName);
50+
@Message(id = 13, value = "Detected driver [%1$s] %2$s")
51+
void detectedDriver(String driverName, String checkmark);
5252

5353
@LogMessage(level = INFO)
5454
@Message(id = 14, value = "Prepared statement cache disabled")

hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/DefaultSqlClientPool.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import java.lang.invoke.MethodHandles;
99
import java.net.URI;
10+
import java.util.ArrayList;
11+
import java.util.List;
1012
import java.util.Map;
1113
import java.util.ServiceConfigurationError;
1214
import java.util.ServiceLoader;
@@ -37,6 +39,7 @@
3739
import io.vertx.sqlclient.spi.Driver;
3840

3941
import static java.util.Collections.singletonList;
42+
import static java.util.stream.Collectors.toList;
4043

4144
/**
4245
* A pool of reactive connections backed by a Vert.x {@link Pool}.
@@ -227,14 +230,27 @@ protected URI jdbcUrl(Map<?,?> configurationValues) {
227230
*/
228231
private Driver findDriver(URI uri, ServiceConfigurationError originalError) {
229232
String scheme = scheme( uri );
233+
List<Driver> selected = new ArrayList<>();
230234
for ( Driver d : ServiceLoader.load( Driver.class ) ) {
231235
String driverName = d.getClass().getCanonicalName();
232-
LOG.detectedDriver( driverName );
233236
if ( matchesScheme( driverName, scheme ) ) {
234-
return d;
237+
LOG.detectedDriver( driverName, "✓" );
238+
selected.add( d );
235239
}
240+
else {
241+
LOG.detectedDriver( driverName, "" );
242+
}
243+
}
244+
if ( selected.isEmpty() ) {
245+
throw new ConfigurationException( "No suitable drivers found for URI scheme: " + scheme, originalError );
246+
}
247+
if ( selected.size() > 1 ) {
248+
List<String> driverClasses = selected.stream()
249+
.map( driver -> driver.getClass().getCanonicalName() )
250+
.collect( toList() );
251+
throw new ConfigurationException( "Multiple drivers found matching for URI scheme \"" + scheme + "\". Please, pick one: " + driverClasses, originalError );
236252
}
237-
throw new ConfigurationException( "No suitable drivers found for URI scheme: " + scheme, originalError );
253+
return selected.get( 0 );
238254
}
239255

240256
private String scheme(URI uri) {

0 commit comments

Comments
 (0)