File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
hibernate-reactive-core/src/main/java/org/hibernate/reactive Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 1111import java .util .Map ;
1212import java .util .concurrent .TimeUnit ;
1313
14+ import org .hibernate .internal .util .StringHelper ;
1415import org .hibernate .reactive .logging .impl .Log ;
1516import org .hibernate .reactive .logging .impl .LoggerFactory ;
1617import org .hibernate .reactive .provider .Settings ;
@@ -95,7 +96,7 @@ public SqlConnectOptions connectOptions(URI uri) {
9596 ? oraclePath ( uri )
9697 : uri .getPath ();
9798
98- String database = path . length () > 0
99+ String database = path != null && ! path . isEmpty ()
99100 ? path .substring ( 1 )
100101 : "" ;
101102
@@ -105,9 +106,6 @@ public SqlConnectOptions connectOptions(URI uri) {
105106 database = database .substring ( 0 , database .indexOf ( ':' ) );
106107 }
107108
108- String host = findHost ( uri , scheme );
109- int port = findPort ( uri , scheme );
110-
111109 //see if the credentials were specified via properties
112110 String username = user ;
113111 String password = pass ;
@@ -183,6 +181,13 @@ else if ( param.startsWith( "database=" ) ) {
183181 }
184182 }
185183
184+ if ( StringHelper .isEmpty ( database ) ) {
185+ throw LOG .couldNotDetermineDialectFromConnectionURI ( uri .toString () );
186+ }
187+
188+ String host = findHost ( uri , scheme );
189+ int port = findPort ( uri , scheme );
190+
186191 if ( username == null ) {
187192 throw LOG .databaseUsernameNotSpecified ();
188193 }
Original file line number Diff line number Diff line change 2929import static java .lang .Integer .parseInt ;
3030import static java .util .Objects .requireNonNullElse ;
3131import static java .util .function .Function .identity ;
32+ import static org .hibernate .cfg .JdbcSettings .ALLOW_METADATA_ON_BOOT ;
3233import static org .hibernate .reactive .util .impl .CompletionStages .completedFuture ;
3334
3435/**
@@ -84,7 +85,7 @@ protected JdbcEnvironmentImpl getJdbcEnvironmentUsingJdbcMetadata(
8485 Integer explicitDatabaseMajorVersion ,
8586 Integer explicitDatabaseMinorVersion ,
8687 String explicitDatabaseVersion ) {
87- try {
88+ if ( configurationValues . containsKey ( ALLOW_METADATA_ON_BOOT ) ) {
8889 final Dialect dialect = new DialectBuilder ( configurationValues , registry )
8990 .build (
9091 dialectFactory ,
@@ -97,7 +98,7 @@ protected JdbcEnvironmentImpl getJdbcEnvironmentUsingJdbcMetadata(
9798 );
9899 return new JdbcEnvironmentImpl ( registry , dialect );
99100 }
100- catch ( RuntimeException e ) {
101+ else {
101102 return getJdbcEnvironmentWithDefaults ( configurationValues , registry , dialectFactory );
102103 }
103104 }
You can’t perform that action at this time.
0 commit comments