Java 6 compatibility.

pull/41/head
Brett Wooldridge 11 years ago
parent 07d630de5a
commit c6d40199c5

@ -181,8 +181,8 @@
<version>3.1</version>
<extensions>true</extensions>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>

@ -121,11 +121,13 @@ public final class HikariConfig implements HikariConfigMBean
throw new IllegalArgumentException("Property file " + propertyFileName + " was not found.");
}
try ( FileInputStream fis = new FileInputStream(propFile) )
try
{
FileInputStream fis = new FileInputStream(propFile);
Properties props = new Properties();
props.load(fis);
PropertyBeanSetter.setTargetFromProperties(this, props);
fis.close();
}
catch (IOException io)
{
@ -419,7 +421,7 @@ public final class HikariConfig implements HikariConfigMBean
int level = field.getInt(null);
this.transactionIsolation = level;
}
catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e)
catch (Exception e)
{
throw new IllegalArgumentException("Invalid transaction isolation value: " + isolationLevel);
}

@ -113,7 +113,7 @@ public final class HikariPool implements HikariPoolMBean
Class<?> clazz = this.getClass().getClassLoader().loadClass(configuration.getConnectionCustomizerClassName());
this.connectionCustomizer = (IConnectionCustomizer) clazz.newInstance();
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException e)
catch (Exception e)
{
throw new RuntimeException("Could not load connection customization class", e);
}
@ -398,10 +398,15 @@ public final class HikariPool implements HikariPoolMBean
if (initSql != null && initSql.length() > 0)
{
connection.setAutoCommit(true);
try (Statement statement = connection.createStatement())
Statement statement = connection.createStatement();
try
{
statement.execute(initSql);
}
finally
{
statement.close();
}
}
if (!shutdown)
@ -462,11 +467,16 @@ public final class HikariPool implements HikariPoolMBean
return connection.isValid((int) TimeUnit.MILLISECONDS.toSeconds(timeoutMs));
}
try (Statement statement = connection.createStatement())
Statement statement = connection.createStatement();
try
{
statement.setQueryTimeout((int) TimeUnit.MILLISECONDS.toSeconds(timeoutMs));
statement.executeQuery(configuration.getConnectionTestQuery());
}
finally
{
statement.close();
}
}
finally
{

@ -72,7 +72,7 @@ public class ConcurrentBag<T extends com.zaxxer.hikari.util.ConcurrentBag.IBagMa
*/
public ConcurrentBag()
{
this.sharedList = new CopyOnWriteArraySet<>();
this.sharedList = new CopyOnWriteArraySet<T>();
this.synchronizer = new Synchronizer();
this.threadList = new ThreadLocal<LinkedList<T>>();
}
@ -92,7 +92,7 @@ public class ConcurrentBag<T extends com.zaxxer.hikari.util.ConcurrentBag.IBagMa
LinkedList<T> list = threadList.get();
if (list == null)
{
list = new LinkedList<>();
list = new LinkedList<T>();
threadList.set(list);
}
@ -193,7 +193,7 @@ public class ConcurrentBag<T extends com.zaxxer.hikari.util.ConcurrentBag.IBagMa
*/
public List<T> values(int state)
{
ArrayList<T> list = new ArrayList<>(sharedList.size());
ArrayList<T> list = new ArrayList<T>(sharedList.size());
if (state == STATE_IN_USE || state == STATE_NOT_IN_USE)
{
for (T reference : sharedList)

@ -14,7 +14,7 @@ public class TestFastStatementList
@Test
public void testOverflow()
{
ArrayList<Statement> verifyList = new ArrayList<>();
ArrayList<Statement> verifyList = new ArrayList<Statement>();
FastStatementList list = new FastStatementList();
for (int i = 0; i < 100; i++)

@ -24,9 +24,10 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import javax.inject.Inject;
import java.io.File;
import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.*;

Loading…
Cancel
Save