Merge pull request #574 from guidomedina/gm-intellij-inspections-and-dependency-updates

IntelliJ inspections fixes and Maven updates
pull/581/merge
Brett Wooldridge 9 years ago
commit bbe692e17a

@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zaxxer</groupId>
@ -40,26 +41,30 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<felix.bundle.plugin.version>3.0.0</felix.bundle.plugin.version>
<felix.bundle.plugin.version>3.0.1</felix.bundle.plugin.version>
<felix.version>5.4.0</felix.version>
<hibernate.version>5.0.2.Final</hibernate.version>
<hibernate.version>5.0.7.Final</hibernate.version>
<javassist.version>3.20.0-GA</javassist.version>
<jndi.version>0.11.4.1</jndi.version>
<maven.release.version>2.5.1</maven.release.version>
<maven.release.version>2.5.3</maven.release.version>
<metrics.version>3.1.2</metrics.version>
<mockito.version>1.10.19</mockito.version>
<pax.exam.version>4.6.0</pax.exam.version>
<pax.url.version>2.4.3</pax.url.version>
<slf4j.version>1.7.12</slf4j.version>
<log4j.version>2.4.1</log4j.version>
<pax.exam.version>4.8.0</pax.exam.version>
<pax.url.version>2.4.5</pax.url.version>
<slf4j.version>1.7.16</slf4j.version>
<log4j.version>2.5</log4j.version>
</properties>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
<version>9</version>
</parent>
<prerequisites>
<maven>3.3.9</maven>
</prerequisites>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
@ -304,7 +309,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<version>3.5.1</version>
<extensions>true</extensions>
<configuration>
<source>1.7</source>
@ -325,7 +330,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<version>2.19.1</version>
<configuration>
<!-- Sets the VM argument line used when unit tests are run. -->
<argLine>${surefireArgLine}</argLine>
@ -386,7 +391,7 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.0.0</version>
<version>4.1.0</version>
<executions>
<execution>
<id>coveralls</id>

@ -100,7 +100,7 @@ public class HikariConfig implements HikariConfigMXBean
final Properties sysProps = System.getProperties();
AtomicInteger poolNumber = (AtomicInteger) sysProps.get("com.zaxxer.hikari.pool_number");
if (poolNumber == null) {
POOL_NUMBER = new AtomicInteger();
POOL_NUMBER = new AtomicInteger();
sysProps.put("com.zaxxer.hikari.pool_number", POOL_NUMBER);
}
else {
@ -179,8 +179,8 @@ public class HikariConfig implements HikariConfigMXBean
/**
* Get the SQL query to be executed to test the validity of connections.
*
* @return the SQL query string, or null
*
* @return the SQL query string, or null
*/
public String getConnectionTestQuery()
{
@ -190,7 +190,7 @@ public class HikariConfig implements HikariConfigMXBean
/**
* Set the SQL query to be executed to test the validity of connections. Using
* the JDBC4 <code>Connection.isValid()</code> method to test connection validity can
* be more efficient on some databases and is recommended. See
* be more efficient on some databases and is recommended. See
* {@link HikariConfig#setJdbc4ConnectionTest(boolean)}.
*
* @param connectionTestQuery a SQL query string
@ -498,7 +498,7 @@ public class HikariConfig implements HikariConfigMXBean
if (metricRegistry instanceof String) {
try {
InitialContext initCtx = new InitialContext();
metricRegistry = (MetricRegistry) initCtx.lookup((String) metricRegistry);
metricRegistry = initCtx.lookup((String) metricRegistry);
}
catch (NamingException e) {
throw new IllegalArgumentException(e);
@ -534,7 +534,7 @@ public class HikariConfig implements HikariConfigMXBean
if (healthCheckRegistry instanceof String) {
try {
InitialContext initCtx = new InitialContext();
healthCheckRegistry = (HealthCheckRegistry) initCtx.lookup((String) healthCheckRegistry);
healthCheckRegistry = initCtx.lookup((String) healthCheckRegistry);
}
catch (NamingException e) {
throw new IllegalArgumentException(e);
@ -709,7 +709,7 @@ public class HikariConfig implements HikariConfigMXBean
/**
* Set the default transaction isolation level. The specified value is the
* constant name from the <code>Connection</code> class, eg.
* constant name from the <code>Connection</code> class, eg.
* <code>TRANSACTION_REPEATABLE_READ</code>.
*
* @param isolationLevel the name of the isolation level
@ -838,7 +838,7 @@ public class HikariConfig implements HikariConfigMXBean
}
if (leakDetectionThreshold > 0 && !unitTest) {
if (leakDetectionThreshold < TimeUnit.SECONDS.toMillis(2) || (leakDetectionThreshold > maxLifetime && maxLifetime > 0)) {
if (leakDetectionThreshold < TimeUnit.SECONDS.toMillis(2) || (leakDetectionThreshold > maxLifetime && maxLifetime > 0)) {
LOGGER.warn("{} - leakDetectionThreshold is less than 2000ms or more than maxLifetime, disabling it.", poolName);
leakDetectionThreshold = 0L;
}

@ -166,7 +166,7 @@ public class HikariDataSource extends HikariConfig implements DataSource, Closea
}
if (unwrappedDataSource != null) {
return (T) unwrappedDataSource.unwrap(iface);
return unwrappedDataSource.unwrap(iface);
}
}

@ -589,7 +589,7 @@ public class HikariPool extends PoolBase implements HikariPoolMXBean, IBagStateL
// Detect retrograde time, allowing +128ms as per NTP spec.
if (clockSource.plusMillis(now, 128) < clockSource.plusMillis(previous, HOUSEKEEPING_PERIOD_MS)) {
LOGGER.warn("{} - Retrograde clock change detected (housekeeper delta={}), soft-evicting connections from pool.",
LOGGER.warn("{} - Retrograde clock change detected (housekeeper delta={}), soft-evicting connections from pool.",
clockSource.elapsedDisplayString(previous, now), poolName);
previous = now;
softEvictConnections();
@ -609,8 +609,8 @@ public class HikariPool extends PoolBase implements HikariPoolMXBean, IBagStateL
int removable = idleList.size() - config.getMinimumIdle();
if (removable > 0) {
logPoolState("Before cleanup ");
afterPrefix = "After cleanup ";
afterPrefix = "After cleanup ";
// Sort pool entries on lastAccessed
Collections.sort(idleList, LASTACCESS_COMPARABLE);
for (PoolEntry poolEntry : idleList) {
@ -618,9 +618,9 @@ public class HikariPool extends PoolBase implements HikariPoolMXBean, IBagStateL
closeConnection(poolEntry, "(connection has passed idleTimeout)");
if (--removable == 0) {
break; // keep min idle cons
};
}
}
}
}
}
}

@ -48,7 +48,7 @@ public abstract class ProxyConnection implements Connection
static final int DIRTY_BIT_ISOLATION = 0b00100;
static final int DIRTY_BIT_CATALOG = 0b01000;
static final int DIRTY_BIT_NETTIMEOUT = 0b10000;
private static final Logger LOGGER;
private static final Set<String> SQL_ERRORS;
private static final ClockSource clockSource;
@ -58,7 +58,7 @@ public abstract class ProxyConnection implements Connection
private final PoolEntry poolEntry;
private final ProxyLeakTask leakTask;
private final FastList<Statement> openStatements;
private int dirtyBits;
private long lastAccess;
private boolean isCommitStateDirty;
@ -171,7 +171,7 @@ public abstract class ProxyConnection implements Connection
final void markCommitStateDirty()
{
if (isAutoCommit) {
lastAccess = clockSource.currentTime();
lastAccess = clockSource.currentTime();
}
else {
isCommitStateDirty = true;
@ -179,7 +179,7 @@ public abstract class ProxyConnection implements Connection
}
/**
*
*
*/
void cancelLeakTask()
{
@ -433,7 +433,7 @@ public abstract class ProxyConnection implements Connection
return (T) delegate;
}
else if (delegate instanceof Wrapper) {
return (T) delegate.unwrap(iface);
return delegate.unwrap(iface);
}
throw new SQLException("Wrapped connection is not an instance of " + iface);
@ -450,12 +450,12 @@ public abstract class ProxyConnection implements Connection
private static Connection getClosedConnection()
{
InvocationHandler handler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
final String methodName = method.getName();
if ("abort".equals(methodName)) {
if ("abort".equals(methodName)) {
return Void.TYPE;
}
else if ("isValid".equals(methodName)) {

@ -98,9 +98,9 @@ public abstract class ProxyResultSet implements ResultSet
return (T) delegate;
}
else if (delegate instanceof Wrapper) {
return (T) delegate.unwrap(iface);
return delegate.unwrap(iface);
}
throw new SQLException("Wrapped ResultSet is not an instance of " + iface);
}
}
}

@ -109,7 +109,7 @@ public abstract class ProxyStatement implements Statement
{
connection.markCommitStateDirty();
ResultSet resultSet = delegate.executeQuery(sql);
return ProxyFactory.getProxyResultSet(connection, this, resultSet);
return ProxyFactory.getProxyResultSet(connection, this, resultSet);
}
/** {@inheritDoc} */
@ -232,7 +232,7 @@ public abstract class ProxyStatement implements Statement
return (T) delegate;
}
else if (delegate instanceof Wrapper) {
return (T) delegate.unwrap(iface);
return delegate.unwrap(iface);
}
throw new SQLException("Wrapped statement is not an instance of " + iface);

@ -30,12 +30,12 @@ import java.util.concurrent.TimeUnit;
/**
* A resolution-independent provider of current time-stamps and elapsed time
* calculations.
*
*
* @author Brett Wooldridge
*/
public interface ClockSource
{
final ClockSource INSTANCE = Factory.create();
ClockSource INSTANCE = Factory.create();
/**
* Get the current time-stamp (resolution is opaque).
@ -94,7 +94,7 @@ public interface ClockSource
/**
* Return the specified opaque time-stamp plus the specified number of milliseconds.
*
* @param time an opaque time-stamp
* @param time an opaque time-stamp
* @param millis milliseconds to add
* @return a new opaque time-stamp
*/
@ -120,7 +120,7 @@ public interface ClockSource
String[] TIMEUNIT_DISPLAY_VALUES = {"ns", "μs", "ms", "s", "m", "h", "d"};
/**
* Factory class used to create a platform-specific ClockSource.
* Factory class used to create a platform-specific ClockSource.
*/
class Factory
{

@ -68,7 +68,7 @@ public final class JavassistProxyFactory
generateProxyClass(Connection.class, ProxyConnection.class.getName(), methodBody);
generateProxyClass(Statement.class, ProxyStatement.class.getName(), methodBody);
generateProxyClass(ResultSet.class, ProxyResultSet.class.getName(), methodBody);
// For these we have to cast the delegate
methodBody = "{ try { return ((cast) delegate).method($$); } catch (SQLException e) { throw checkException(e); } }";
generateProxyClass(PreparedStatement.class, ProxyPreparedStatement.class.getName(), methodBody);
@ -119,7 +119,7 @@ public final class JavassistProxyFactory
CtClass superCt = classPool.getCtClass(superClassName);
CtClass targetCt = classPool.makeClass(newClassName, superCt);
targetCt.setModifiers(Modifier.FINAL);
targetCt.setModifiers(Modifier.FINAL);
System.out.println("Generating " + newClassName);
@ -216,10 +216,10 @@ public final class JavassistProxyFactory
return intf.getDeclaredMethod(intfMethod.getName(), paramTypes.toArray(new Class[paramTypes.size()])).toString().contains("default ");
}
private static Set<Class<?>> getAllInterfaces(Class<?> clazz)
{
Set<Class<?>> interfaces = new HashSet<Class<?>>();
Set<Class<?>> interfaces = new HashSet<>();
for (Class<?> intf : Arrays.asList(clazz.getInterfaces())) {
if (intf.getInterfaces().length > 0) {
interfaces.addAll(getAllInterfaces(intf));

@ -45,7 +45,7 @@ public interface Sequence
/**
* Factory class used to create a platform-specific ClockSource.
*/
public final class Factory
final class Factory
{
public static Sequence create()
{

@ -34,7 +34,7 @@ public class ConnectionRaceConditionTest
TestElf.setSlf4jLogLevel(ConcurrentBag.class, Level.INFO);
final AtomicReference<Exception> ref = new AtomicReference<Exception>(null);
final AtomicReference<Exception> ref = new AtomicReference<>(null);
// Initialize HikariPool with no initial connections and room to grow
try (final HikariDataSource ds = new HikariDataSource(config)) {

@ -47,8 +47,7 @@ public class MiscTest
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
TestElf.setConfigUnitTest(true);
final HikariDataSource ds = new HikariDataSource(config);
try {
try (HikariDataSource ds = new HikariDataSource(config)) {
PrintWriter writer = new PrintWriter(System.out);
ds.setLogWriter(writer);
Assert.assertSame(writer, ds.getLogWriter());
@ -57,7 +56,6 @@ public class MiscTest
finally
{
TestElf.setConfigUnitTest(false);
ds.close();
}
}
@ -102,8 +100,7 @@ public class MiscTest
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
TestElf.setConfigUnitTest(true);
final HikariDataSource ds = new HikariDataSource(config);
try {
try (HikariDataSource ds = new HikariDataSource(config)) {
TestElf.setSlf4jLogLevel(HikariPool.class, Level.DEBUG);
TestElf.getPool(ds).logPoolState();
@ -119,7 +116,6 @@ public class MiscTest
finally
{
TestElf.setConfigUnitTest(false);
ds.close();
}
}
}

@ -92,7 +92,7 @@ public class PostgresTest
try (Connection conn = ds.getConnection()) {
System.err.println("\nGot a connection, and released it. Now, enable the firewall.");
}
TestElf.getPool(ds).logPoolState();
UtilityElf.quietlySleep(5000L);
@ -142,7 +142,7 @@ public class PostgresTest
catch (SQLException e) {
// expected
}
};
}
}.start();
}
@ -189,10 +189,10 @@ public class PostgresTest
e.printStackTrace();
// throw new RuntimeException(e);
}
// UtilityElf.quietlySleep(10L); //Math.max(50L, (long)(Math.random() * 250L)));
} while (ClockSource.INSTANCE.elapsedMillis(start) < TimeUnit.MINUTES.toMillis(5));
};
}
});
}

@ -304,7 +304,7 @@ public class ShutdownTest
try { connection.close(); } catch (SQLException e) { e.printStackTrace(); }
ds.close();
}
};
}
};
t.start();
@ -318,7 +318,7 @@ public class ShutdownTest
catch (IllegalStateException e) {
Assert.fail(e.getMessage());
}
};
}
};
t2.start();

@ -63,7 +63,7 @@ public class TestConcurrentBag
@Test
public void testConcurrentBag() throws Exception
{
ConcurrentBag<PoolEntry> bag = new ConcurrentBag<PoolEntry>( new IBagStateListener() {
ConcurrentBag<PoolEntry> bag = new ConcurrentBag<>(new IBagStateListener() {
@Override
public Future<Boolean> addBagItem()
{

@ -14,9 +14,9 @@ public class TestFastList
@Test
public void testAddRemove()
{
ArrayList<Statement> verifyList = new ArrayList<Statement>();
ArrayList<Statement> verifyList = new ArrayList<>();
FastList<Statement> list = new FastList<Statement>(Statement.class);
FastList<Statement> list = new FastList<>(Statement.class);
for (int i = 0; i < 32; i++)
{
StubStatement statement = new StubStatement(null);
@ -36,9 +36,9 @@ public class TestFastList
@Test
public void testAddRemoveTail()
{
ArrayList<Statement> verifyList = new ArrayList<Statement>();
ArrayList<Statement> verifyList = new ArrayList<>();
FastList<Statement> list = new FastList<Statement>(Statement.class);
FastList<Statement> list = new FastList<>(Statement.class);
for (int i = 0; i < 32; i++)
{
StubStatement statement = new StubStatement(null);
@ -58,9 +58,9 @@ public class TestFastList
@Test
public void testOverflow()
{
ArrayList<Statement> verifyList = new ArrayList<Statement>();
ArrayList<Statement> verifyList = new ArrayList<>();
FastList<Statement> list = new FastList<Statement>(Statement.class);
FastList<Statement> list = new FastList<>(Statement.class);
for (int i = 0; i < 100; i++)
{
StubStatement statement = new StubStatement(null);
@ -78,7 +78,7 @@ public class TestFastList
@Test
public void testClear()
{
FastList<Statement> list = new FastList<Statement>(Statement.class);
FastList<Statement> list = new FastList<>(Statement.class);
for (int i = 0; i < 100; i++)
{
StubStatement statement = new StubStatement(null);
@ -93,7 +93,7 @@ public class TestFastList
@Test
public void testRemoveLast()
{
FastList<Statement> list = new FastList<Statement>(Statement.class);
FastList<Statement> list = new FastList<>(Statement.class);
Statement last = null;
for (int i = 0; i < 100; i++)
@ -106,19 +106,19 @@ public class TestFastList
Assert.assertEquals(last, list.removeLast());
Assert.assertEquals(99, list.size());
}
@Test
public void testPolyMorphism1()
{
class Foo implements Base2 {
}
class Bar extends Foo {
}
FastList<Base> list = new FastList<Base>(Base.class, 2);
FastList<Base> list = new FastList<>(Base.class, 2);
list.add(new Foo());
list.add(new Foo());
list.add(new Bar());
@ -126,11 +126,11 @@ public class TestFastList
interface Base
{
}
interface Base2 extends Base
{
}
}

@ -25,8 +25,7 @@ public class TestProxies
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
HikariDataSource ds = new HikariDataSource(config);
try {
try (HikariDataSource ds = new HikariDataSource(config)) {
Connection conn = ds.getConnection();
Assert.assertNotNull(conn.createStatement(ResultSet.FETCH_FORWARD, ResultSet.TYPE_SCROLL_INSENSITIVE));
@ -53,9 +52,6 @@ public class TestProxies
// pass
}
}
finally {
ds.close();
}
}
@Test
@ -67,8 +63,7 @@ public class TestProxies
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
HikariDataSource ds = new HikariDataSource(config);
try {
try (HikariDataSource ds = new HikariDataSource(config)) {
Connection conn = ds.getConnection();
PreparedStatement stmt = conn.prepareStatement("some sql");
@ -87,9 +82,6 @@ public class TestProxies
// pass
}
}
finally {
ds.close();
}
}
@Test
@ -102,8 +94,7 @@ public class TestProxies
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
HikariDataSource ds = new HikariDataSource(config);
try {
try (HikariDataSource ds = new HikariDataSource(config)) {
Connection conn = ds.getConnection();
StubConnection stubConnection = conn.unwrap(StubConnection.class);
stubConnection.throwException = true;
@ -204,9 +195,6 @@ public class TestProxies
// pass
}
}
finally {
ds.close();
}
}
@Test
@ -218,8 +206,7 @@ public class TestProxies
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
HikariDataSource ds = new HikariDataSource(config);
try {
try (HikariDataSource ds = new HikariDataSource(config)) {
Connection conn = ds.getConnection();
StubConnection stubConnection = conn.unwrap(StubConnection.class);
stubConnection.throwException = true;
@ -311,8 +298,5 @@ public class TestProxies
Assert.fail();
}
}
finally {
ds.close();
}
}
}

@ -42,21 +42,16 @@ public class UnwrapTest
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
HikariDataSource ds = new HikariDataSource(config);
try (HikariDataSource ds = new HikariDataSource(config)) {
ds.getConnection().close();
Assert.assertSame("Idle connections not as expected", 1, TestElf.getPool(ds).getIdleConnections());
try {
ds.getConnection().close();
Assert.assertSame("Idle connections not as expected", 1, TestElf.getPool(ds).getIdleConnections());
Connection connection = ds.getConnection();
Assert.assertNotNull(connection);
StubConnection unwrapped = connection.unwrap(StubConnection.class);
Assert.assertTrue("unwrapped connection is not instance of StubConnection: " + unwrapped, (unwrapped != null && unwrapped instanceof StubConnection));
}
finally {
ds.close();
}
Connection connection = ds.getConnection();
Assert.assertNotNull(connection);
StubConnection unwrapped = connection.unwrap(StubConnection.class);
Assert.assertTrue("unwrapped connection is not instance of StubConnection: " + unwrapped, (unwrapped != null && unwrapped instanceof StubConnection));
}
}
@Test
@ -69,8 +64,7 @@ public class UnwrapTest
config.setConnectionTestQuery("VALUES 1");
config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
HikariDataSource ds = new HikariDataSource(config);
try {
try (HikariDataSource ds = new HikariDataSource(config)) {
StubDataSource unwrap = ds.unwrap(StubDataSource.class);
Assert.assertNotNull(unwrap);
Assert.assertTrue(unwrap instanceof StubDataSource);
@ -86,8 +80,5 @@ public class UnwrapTest
Assert.assertTrue(e.getMessage().contains("Wrapped DataSource"));
}
}
finally {
ds.close();
}
}
}

Loading…
Cancel
Save