From 82b376c5f6f5cafca6381adab8764fb6f525c672 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Sat, 15 Nov 2014 19:04:17 +0000 Subject: [PATCH] HHH-9498 Using C3P0 connection pool but not setting hibernate.connection.isolation results in a NumberFormatException --- .../c3p0/internal/C3P0ConnectionProvider.java | 3 ++- .../test/c3p0/C3P0ConnectionProviderTest.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java b/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java index 6f55c363dc..c288282346 100644 --- a/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java +++ b/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java @@ -38,6 +38,7 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.cfg.Environment; import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.UnknownUnwrapTypeException; import org.hibernate.service.spi.Configurable; @@ -214,7 +215,7 @@ public class C3P0ConnectionProvider } final String i = (String) props.get( Environment.ISOLATION ); - if ( i == null ) { + if ( StringHelper.isEmpty( i ) ) { isolation = null; } else { diff --git a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java index 904806f366..9840f45447 100644 --- a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java +++ b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java @@ -24,14 +24,17 @@ package org.hibernate.test.c3p0; import java.lang.management.ManagementFactory; +import java.util.Properties; import java.util.Set; import javax.management.MBeanServer; import javax.management.ObjectName; import org.hibernate.c3p0.internal.C3P0ConnectionProvider; +import org.hibernate.cfg.Environment; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.spi.JdbcServices; +import org.hibernate.testing.TestForIssue; import org.junit.Test; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -89,4 +92,12 @@ public class C3P0ConnectionProviderTest extends BaseCoreFunctionalTestCase { assertTrue( "PooledDataSource BMean not found, please verify version of c3p0", mbeanfound ); } + + @Test @TestForIssue(jiraKey="HHH-9498") + public void testIsolationPropertyCouldBeEmpty() { + Properties configuration = new Properties(); + configuration.setProperty( Environment.ISOLATION, "" ); + C3P0ConnectionProvider provider = new C3P0ConnectionProvider(); + provider.configure( configuration ); + } }