|
17 | 17 | import org.hibernate.boot.registry.StandardServiceInitiator; |
18 | 18 | import org.hibernate.boot.registry.selector.spi.StrategySelector; |
19 | 19 | import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; |
| 20 | +import org.hibernate.engine.jdbc.connections.spi.ConnectionProviderConfigurationException; |
20 | 21 | import org.hibernate.internal.CoreLogging; |
21 | 22 | import org.hibernate.internal.CoreMessageLogger; |
22 | | -import org.hibernate.internal.util.StringHelper; |
23 | 23 | import org.hibernate.resource.beans.container.spi.BeanContainer; |
24 | 24 | import org.hibernate.resource.beans.internal.Helper; |
25 | 25 | import org.hibernate.service.spi.ServiceRegistryImplementor; |
|
43 | 43 | import static org.hibernate.cfg.JdbcSettings.USER; |
44 | 44 | import static org.hibernate.cfg.SchemaToolingSettings.ENABLE_SYNONYMS; |
45 | 45 | import static org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.isMultiTenancyEnabled; |
| 46 | +import static org.hibernate.internal.util.StringHelper.isBlank; |
46 | 47 | import static org.hibernate.internal.util.StringHelper.nullIfEmpty; |
47 | 48 |
|
48 | 49 | /** |
@@ -325,29 +326,38 @@ public static Integer interpretIsolation(Object setting) { |
325 | 326 | return null; |
326 | 327 | } |
327 | 328 | else if ( setting instanceof Number number ) { |
328 | | - return number.intValue(); |
| 329 | + final int isolationLevel = number.intValue(); |
| 330 | + checkIsolationLevel( isolationLevel ); |
| 331 | + return isolationLevel; |
329 | 332 | } |
330 | 333 | else { |
331 | 334 | final String string = setting.toString(); |
332 | | - if ( StringHelper.isEmpty( string ) ) { |
| 335 | + if ( isBlank( string ) ) { |
333 | 336 | return null; |
334 | 337 | } |
335 | 338 | else if ( ISOLATION_VALUE_MAP.containsKey( string ) ) { |
336 | 339 | return ISOLATION_VALUE_MAP.get( string ); |
337 | 340 | } |
338 | 341 | else { |
339 | | - // it could be a String representation of the isolation numeric value... |
| 342 | + // it could be a String representation of the isolation numeric value |
340 | 343 | try { |
341 | | - return Integer.valueOf( string ); |
| 344 | + final int isolationLevel = Integer.parseInt( string ); |
| 345 | + checkIsolationLevel( isolationLevel ); |
| 346 | + return isolationLevel; |
342 | 347 | } |
343 | 348 | catch (NumberFormatException ignore) { |
| 349 | + throw new ConnectionProviderConfigurationException( "Unknown transaction isolation level: '" + string + "'" ); |
344 | 350 | } |
345 | | - |
346 | | - throw new HibernateException("Could not interpret transaction isolation setting [" + setting + "]"); |
347 | 351 | } |
348 | 352 | } |
349 | 353 | } |
350 | 354 |
|
| 355 | + private static void checkIsolationLevel(int isolationLevel) { |
| 356 | + if ( !ISOLATION_VALUE_CONSTANT_NAME_MAP.containsKey( isolationLevel ) ) { |
| 357 | + throw new ConnectionProviderConfigurationException( "Unknown transaction isolation level: " + isolationLevel ); |
| 358 | + } |
| 359 | + } |
| 360 | + |
351 | 361 | /** |
352 | 362 | * Gets the {@link Connection} constant name corresponding to the given isolation. |
353 | 363 | * |
|
0 commit comments