Add final modifier to local variables. Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/e2c137f9 Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/e2c137f9 Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/e2c137f9
Branch: refs/heads/master Commit: e2c137f955cbc8c34366eed9fdc098f27cb5d06e Parents: 41e682d Author: Gary Gregory <[email protected]> Authored: Sun May 6 10:20:39 2018 -0600 Committer: Gary Gregory <[email protected]> Committed: Sun May 6 10:20:39 2018 -0600 ---------------------------------------------------------------------- .../commons/dbutils/AbstractQueryRunner.java | 38 +- .../commons/dbutils/AsyncQueryRunner.java | 6 +- .../commons/dbutils/BasicRowProcessor.java | 28 +- .../apache/commons/dbutils/BeanProcessor.java | 60 +- .../org/apache/commons/dbutils/DbUtils.java | 33 +- .../apache/commons/dbutils/OutParameter.java | 2 +- .../org/apache/commons/dbutils/QueryLoader.java | 1 + .../org/apache/commons/dbutils/QueryRunner.java | 40 +- .../commons/dbutils/ResultSetIterator.java | 6 +- .../dbutils/handlers/AbstractKeyedHandler.java | 2 +- .../dbutils/handlers/AbstractListHandler.java | 2 +- .../properties/DatePropertyHandler.java | 4 +- .../wrappers/SqlNullCheckedResultSet.java | 14 +- .../commons/dbutils/AsyncQueryRunnerTest.java | 32 +- .../dbutils/BaseResultSetHandlerTest.java | 8 +- .../commons/dbutils/BasicRowProcessorTest.java | 6 +- .../commons/dbutils/BeanProcessorTest.java | 24 +- .../org/apache/commons/dbutils/DbUtilsTest.java | 570 +++++++++---------- .../dbutils/GenerousBeanProcessorTest.java | 8 +- .../apache/commons/dbutils/MockResultSet.java | 38 +- .../commons/dbutils/MockResultSetMetaData.java | 6 +- .../apache/commons/dbutils/QueryLoaderTest.java | 12 +- .../apache/commons/dbutils/QueryRunnerTest.java | 66 +-- .../commons/dbutils/ResultSetIteratorTest.java | 14 +- .../commons/dbutils/ServiceLoaderTest.java | 8 +- .../dbutils/StatementConfigurationTest.java | 8 +- .../dbutils/handlers/ArrayHandlerTest.java | 8 +- .../dbutils/handlers/ArrayListHandlerTest.java | 10 +- .../dbutils/handlers/BeanHandlerTest.java | 16 +- .../dbutils/handlers/BeanListHandlerTest.java | 22 +- .../dbutils/handlers/ColumnListHandlerTest.java | 16 +- .../dbutils/handlers/KeyedHandlerTest.java | 28 +- .../dbutils/handlers/MapHandlerTest.java | 8 +- .../dbutils/handlers/MapListHandlerTest.java | 10 +- .../dbutils/handlers/ScalarHandlerTest.java | 16 +- .../properties/DatePropertyHandlerTest.java | 2 +- .../properties/PropertyHandlerTest.java | 4 +- .../wrappers/SqlNullCheckedResultSetTest.java | 88 +-- .../wrappers/StringTrimmedResultSetTest.java | 4 +- 39 files changed, 636 insertions(+), 632 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java index 2ed174e..13bb1db 100644 --- a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java +++ b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java @@ -281,15 +281,15 @@ public abstract class AbstractQueryRunner { if (pmd == null) { // can be returned by implementations that don't support the method pmdKnownBroken = true; } else { - int stmtCount = pmd.getParameterCount(); - int paramsCount = params == null ? 0 : params.length; + final int stmtCount = pmd.getParameterCount(); + final int paramsCount = params == null ? 0 : params.length; if (stmtCount != paramsCount) { throw new SQLException("Wrong number of parameters: expected " + stmtCount + ", was given " + paramsCount); } } - } catch (SQLFeatureNotSupportedException ex) { + } catch (final SQLFeatureNotSupportedException ex) { pmdKnownBroken = true; } // TODO see DBUTILS-117: would it make sense to catch any other SQLEx types here? @@ -326,7 +326,7 @@ public abstract class AbstractQueryRunner { * be null here. */ sqlType = pmd.getParameterType(i + 1); - } catch (SQLException e) { + } catch (final SQLException e) { pmdKnownBroken = true; } } @@ -351,24 +351,24 @@ public abstract class AbstractQueryRunner { */ public void fillStatementWithBean(final PreparedStatement stmt, final Object bean, final PropertyDescriptor[] properties) throws SQLException { - Object[] params = new Object[properties.length]; + final Object[] params = new Object[properties.length]; for (int i = 0; i < properties.length; i++) { - PropertyDescriptor property = properties[i]; + final PropertyDescriptor property = properties[i]; Object value = null; - Method method = property.getReadMethod(); + final Method method = property.getReadMethod(); if (method == null) { throw new RuntimeException("No read method for bean property " + bean.getClass() + " " + property.getName()); } try { value = method.invoke(bean, new Object[0]); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new RuntimeException("Couldn't invoke method: " + method, e); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { throw new RuntimeException( "Couldn't invoke method with 0 arguments: " + method, e); - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { throw new RuntimeException("Couldn't invoke method: " + method, e); } @@ -398,20 +398,20 @@ public abstract class AbstractQueryRunner { try { descriptors = Introspector.getBeanInfo(bean.getClass()) .getPropertyDescriptors(); - } catch (IntrospectionException e) { + } catch (final IntrospectionException e) { throw new RuntimeException("Couldn't introspect bean " + bean.getClass().toString(), e); } - PropertyDescriptor[] sorted = new PropertyDescriptor[propertyNames.length]; + final PropertyDescriptor[] sorted = new PropertyDescriptor[propertyNames.length]; for (int i = 0; i < propertyNames.length; i++) { - String propertyName = propertyNames[i]; + final String propertyName = propertyNames[i]; if (propertyName == null) { throw new NullPointerException("propertyName can't be null: " + i); } boolean found = false; for (int j = 0; j < descriptors.length; j++) { - PropertyDescriptor descriptor = descriptors[j]; + final PropertyDescriptor descriptor = descriptors[j]; if (propertyName.equals(descriptor.getName())) { sorted[i] = descriptor; found = true; @@ -517,10 +517,11 @@ public abstract class AbstractQueryRunner { throws SQLException { @SuppressWarnings("resource") + final PreparedStatement ps = conn.prepareStatement(sql); try { configureStatement(ps); - } catch (SQLException e) { + } catch (final SQLException e) { ps.close(); throw e; } @@ -554,10 +555,11 @@ public abstract class AbstractQueryRunner { throws SQLException { @SuppressWarnings("resource") + final PreparedStatement ps = conn.prepareStatement(sql, returnedKeys); try { configureStatement(ps); - } catch (SQLException e) { + } catch (final SQLException e) { ps.close(); throw e; } @@ -588,7 +590,7 @@ public abstract class AbstractQueryRunner { if (causeMessage == null) { causeMessage = ""; } - StringBuffer msg = new StringBuffer(causeMessage); + final StringBuffer msg = new StringBuffer(causeMessage); msg.append(" Query: "); msg.append(sql); @@ -600,7 +602,7 @@ public abstract class AbstractQueryRunner { msg.append(Arrays.deepToString(params)); } - SQLException e = new SQLException(msg.toString(), cause.getSQLState(), + final SQLException e = new SQLException(msg.toString(), cause.getSQLState(), cause.getErrorCode()); e.setNextException(cause); http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/AsyncQueryRunner.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/AsyncQueryRunner.java b/src/main/java/org/apache/commons/dbutils/AsyncQueryRunner.java index 94a29b2..0b6540c 100644 --- a/src/main/java/org/apache/commons/dbutils/AsyncQueryRunner.java +++ b/src/main/java/org/apache/commons/dbutils/AsyncQueryRunner.java @@ -150,7 +150,7 @@ public class AsyncQueryRunner extends AbstractQueryRunner { try { ret = ps.executeBatch(); - } catch (SQLException e) { + } catch (final SQLException e) { rethrow(e, sql, (Object[])params); } finally { close(ps); @@ -256,7 +256,7 @@ public class AsyncQueryRunner extends AbstractQueryRunner { try { rs = wrap(ps.executeQuery()); ret = rsh.handle(rs); - } catch (SQLException e) { + } catch (final SQLException e) { rethrow(e, sql, params); } finally { try { @@ -409,7 +409,7 @@ public class AsyncQueryRunner extends AbstractQueryRunner { try { rows = ps.executeUpdate(); - } catch (SQLException e) { + } catch (final SQLException e) { rethrow(e, sql, params); } finally { close(ps); http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java b/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java index 06c276e..afffbd6 100644 --- a/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java +++ b/src/main/java/org/apache/commons/dbutils/BasicRowProcessor.java @@ -100,9 +100,9 @@ public class BasicRowProcessor implements RowProcessor { */ @Override public Object[] toArray(final ResultSet rs) throws SQLException { - ResultSetMetaData meta = rs.getMetaData(); - int cols = meta.getColumnCount(); - Object[] result = new Object[cols]; + final ResultSetMetaData meta = rs.getMetaData(); + final int cols = meta.getColumnCount(); + final Object[] result = new Object[cols]; for (int i = 0; i < cols; i++) { result[i] = rs.getObject(i + 1); @@ -161,9 +161,9 @@ public class BasicRowProcessor implements RowProcessor { */ @Override public Map<String, Object> toMap(final ResultSet rs) throws SQLException { - ResultSetMetaData rsmd = rs.getMetaData(); - int cols = rsmd.getColumnCount(); - Map<String, Object> result = createCaseInsensitiveHashMap(cols); + final ResultSetMetaData rsmd = rs.getMetaData(); + final int cols = rsmd.getColumnCount(); + final Map<String, Object> result = createCaseInsensitiveHashMap(cols); for (int i = 1; i <= cols; i++) { String columnName = rsmd.getColumnLabel(i); @@ -224,7 +224,7 @@ public class BasicRowProcessor implements RowProcessor { /** {@inheritDoc} */ @Override public boolean containsKey(final Object key) { - Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH)); + final Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH)); return super.containsKey(realKey); // Possible optimisation here: // Since the lowerCaseMap contains a mapping for all the keys, @@ -235,7 +235,7 @@ public class BasicRowProcessor implements RowProcessor { /** {@inheritDoc} */ @Override public Object get(final Object key) { - Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH)); + final Object realKey = lowerCaseMap.get(key.toString().toLowerCase(Locale.ENGLISH)); return super.get(realKey); } @@ -249,8 +249,8 @@ public class BasicRowProcessor implements RowProcessor { * (That's why we call super.remove(oldKey) and not just * super.put(key, value)) */ - Object oldKey = lowerCaseMap.put(key.toLowerCase(Locale.ENGLISH), key); - Object oldValue = super.remove(oldKey); + final Object oldKey = lowerCaseMap.put(key.toLowerCase(Locale.ENGLISH), key); + final Object oldValue = super.remove(oldKey); super.put(key, value); return oldValue; } @@ -258,9 +258,9 @@ public class BasicRowProcessor implements RowProcessor { /** {@inheritDoc} */ @Override public void putAll(final Map<? extends String, ?> m) { - for (Map.Entry<? extends String, ?> entry : m.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); + for (final Map.Entry<? extends String, ?> entry : m.entrySet()) { + final String key = entry.getKey(); + final Object value = entry.getValue(); this.put(key, value); } } @@ -268,7 +268,7 @@ public class BasicRowProcessor implements RowProcessor { /** {@inheritDoc} */ @Override public Object remove(final Object key) { - Object realKey = lowerCaseMap.remove(key.toString().toLowerCase(Locale.ENGLISH)); + final Object realKey = lowerCaseMap.remove(key.toString().toLowerCase(Locale.ENGLISH)); return super.remove(realKey); } } http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/BeanProcessor.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java index caee455..0f0b7ce 100644 --- a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java +++ b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java @@ -85,12 +85,12 @@ public class BeanProcessor { primitiveDefaults.put(Character.TYPE, Character.valueOf((char) 0)); // Use a ServiceLoader to find implementations - for (ColumnHandler handler : ServiceLoader.load(ColumnHandler.class)) { + for (final ColumnHandler handler : ServiceLoader.load(ColumnHandler.class)) { columnHandlers.add(handler); } // Use a ServiceLoader to find implementations - for (PropertyHandler handler : ServiceLoader.load(PropertyHandler.class)) { + for (final PropertyHandler handler : ServiceLoader.load(PropertyHandler.class)) { propertyHandlers.add(handler); } } @@ -150,7 +150,7 @@ public class BeanProcessor { * @return the newly created bean */ public <T> T toBean(final ResultSet rs, final Class<? extends T> type) throws SQLException { - T bean = this.newInstance(type); + final T bean = this.newInstance(type); return this.populateBean(rs, bean); } @@ -188,15 +188,15 @@ public class BeanProcessor { * @return the newly created List of beans */ public <T> List<T> toBeanList(final ResultSet rs, final Class<? extends T> type) throws SQLException { - List<T> results = new ArrayList<>(); + final List<T> results = new ArrayList<>(); if (!rs.next()) { return results; } - PropertyDescriptor[] props = this.propertyDescriptors(type); - ResultSetMetaData rsmd = rs.getMetaData(); - int[] columnToProperty = this.mapColumnsToProperties(rsmd, props); + final PropertyDescriptor[] props = this.propertyDescriptors(type); + final ResultSetMetaData rsmd = rs.getMetaData(); + final int[] columnToProperty = this.mapColumnsToProperties(rsmd, props); do { results.add(this.createBean(rs, type, props, columnToProperty)); @@ -219,7 +219,7 @@ public class BeanProcessor { final PropertyDescriptor[] props, final int[] columnToProperty) throws SQLException { - T bean = this.newInstance(type); + final T bean = this.newInstance(type); return populateBean(rs, bean, props, columnToProperty); } @@ -232,9 +232,9 @@ public class BeanProcessor { * @throws SQLException if a database error occurs. */ public <T> T populateBean(final ResultSet rs, final T bean) throws SQLException { - PropertyDescriptor[] props = this.propertyDescriptors(bean.getClass()); - ResultSetMetaData rsmd = rs.getMetaData(); - int[] columnToProperty = this.mapColumnsToProperties(rsmd, props); + final PropertyDescriptor[] props = this.propertyDescriptors(bean.getClass()); + final ResultSetMetaData rsmd = rs.getMetaData(); + final int[] columnToProperty = this.mapColumnsToProperties(rsmd, props); return populateBean(rs, bean, props, columnToProperty); } @@ -260,8 +260,8 @@ public class BeanProcessor { continue; } - PropertyDescriptor prop = props[columnToProperty[i]]; - Class<?> propType = prop.getPropertyType(); + final PropertyDescriptor prop = props[columnToProperty[i]]; + final Class<?> propType = prop.getPropertyType(); Object value = null; if(propType != null) { @@ -289,15 +289,15 @@ public class BeanProcessor { private void callSetter(final Object target, final PropertyDescriptor prop, Object value) throws SQLException { - Method setter = getWriteMethod(target, prop, value); + final Method setter = getWriteMethod(target, prop, value); if (setter == null || setter.getParameterTypes().length != 1) { return; } try { - Class<?> firstParam = setter.getParameterTypes()[0]; - for (PropertyHandler handler : propertyHandlers) { + final Class<?> firstParam = setter.getParameterTypes()[0]; + for (final PropertyHandler handler : propertyHandlers) { if (handler.match(firstParam, value)) { value = handler.apply(firstParam, value); break; @@ -314,15 +314,15 @@ public class BeanProcessor { // value cannot be null here because isCompatibleType allows null } - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { throw new SQLException( "Cannot set " + prop.getName() + ": " + e.getMessage()); - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { throw new SQLException( "Cannot set " + prop.getName() + ": " + e.getMessage()); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new SQLException( "Cannot set " + prop.getName() + ": " + e.getMessage()); } @@ -363,16 +363,16 @@ public class BeanProcessor { try { // see if there is a "TYPE" field. This is present for primitive wrappers. - Field typeField = valueType.getField("TYPE"); - Object primitiveValueType = typeField.get(valueType); + final Field typeField = valueType.getField("TYPE"); + final Object primitiveValueType = typeField.get(valueType); if (targetType == primitiveValueType) { return true; } - } catch (NoSuchFieldException e) { + } catch (final NoSuchFieldException e) { // lacking the TYPE field is a good sign that we're not working with a primitive wrapper. // we can't match for compatibility - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { // an inaccessible TYPE field is a good sign that we're not working with a primitive wrapper. // nothing to do. we can't match for compatibility } @@ -389,7 +389,7 @@ public class BeanProcessor { * there is no suitable write method. */ protected Method getWriteMethod(final Object target, final PropertyDescriptor prop, final Object value) { - Method method = prop.getWriteMethod(); + final Method method = prop.getWriteMethod(); return method; } @@ -407,11 +407,11 @@ public class BeanProcessor { try { return c.newInstance(); - } catch (InstantiationException e) { + } catch (final InstantiationException e) { throw new SQLException( "Cannot create " + c.getName() + ": " + e.getMessage()); - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { throw new SQLException( "Cannot create " + c.getName() + ": " + e.getMessage()); } @@ -431,7 +431,7 @@ public class BeanProcessor { try { beanInfo = Introspector.getBeanInfo(c); - } catch (IntrospectionException e) { + } catch (final IntrospectionException e) { throw new SQLException( "Bean introspection failed: " + e.getMessage()); } @@ -459,8 +459,8 @@ public class BeanProcessor { protected int[] mapColumnsToProperties(final ResultSetMetaData rsmd, final PropertyDescriptor[] props) throws SQLException { - int cols = rsmd.getColumnCount(); - int[] columnToProperty = new int[cols + 1]; + final int cols = rsmd.getColumnCount(); + final int[] columnToProperty = new int[cols + 1]; Arrays.fill(columnToProperty, PROPERTY_NOT_FOUND); for (int col = 1; col <= cols; col++) { @@ -520,7 +520,7 @@ public class BeanProcessor { return null; } - for (ColumnHandler handler : columnHandlers) { + for (final ColumnHandler handler : columnHandlers) { if (handler.match(propType)) { retval = handler.apply(rs, index); break; http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/DbUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/DbUtils.java b/src/main/java/org/apache/commons/dbutils/DbUtils.java index d65d277..fc61af3 100644 --- a/src/main/java/org/apache/commons/dbutils/DbUtils.java +++ b/src/main/java/org/apache/commons/dbutils/DbUtils.java @@ -94,7 +94,7 @@ public final class DbUtils { public static void closeQuietly(final Connection conn) { try { close(conn); - } catch (SQLException e) { // NOPMD + } catch (final SQLException e) { // NOPMD // quiet } } @@ -132,7 +132,7 @@ public final class DbUtils { public static void closeQuietly(final ResultSet rs) { try { close(rs); - } catch (SQLException e) { // NOPMD + } catch (final SQLException e) { // NOPMD // quiet } } @@ -146,7 +146,7 @@ public final class DbUtils { public static void closeQuietly(final Statement stmt) { try { close(stmt); - } catch (SQLException e) { // NOPMD + } catch (final SQLException e) { // NOPMD // quiet } } @@ -176,7 +176,7 @@ public final class DbUtils { public static void commitAndCloseQuietly(final Connection conn) { try { commitAndClose(conn); - } catch (SQLException e) { // NOPMD + } catch (final SQLException e) { // NOPMD // quiet } } @@ -203,33 +203,34 @@ public final class DbUtils { */ public static boolean loadDriver(final ClassLoader classLoader, final String driverClassName) { try { - Class<?> loadedClass = classLoader.loadClass(driverClassName); + final Class<?> loadedClass = classLoader.loadClass(driverClassName); if (!Driver.class.isAssignableFrom(loadedClass)) { return false; } @SuppressWarnings("unchecked") // guarded by previous check + final Class<Driver> driverClass = (Class<Driver>) loadedClass; - Constructor<Driver> driverConstructor = driverClass.getConstructor(); + final Constructor<Driver> driverConstructor = driverClass.getConstructor(); // make Constructor accessible if it is private - boolean isConstructorAccessible = driverConstructor.isAccessible(); + final boolean isConstructorAccessible = driverConstructor.isAccessible(); if (!isConstructorAccessible) { driverConstructor.setAccessible(true); } try { - Driver driver = driverConstructor.newInstance(); + final Driver driver = driverConstructor.newInstance(); registerDriver(new DriverProxy(driver)); } finally { driverConstructor.setAccessible(isConstructorAccessible); } return true; - } catch (RuntimeException e) { + } catch (final RuntimeException e) { return false; - } catch (Exception e) { + } catch (final Exception e) { return false; } } @@ -281,7 +282,7 @@ public final class DbUtils { if (conn != null) { try { printStackTrace(conn.getWarnings(), pw); - } catch (SQLException e) { + } catch (final SQLException e) { printStackTrace(e, pw); } } @@ -326,7 +327,7 @@ public final class DbUtils { public static void rollbackAndCloseQuietly(final Connection conn) { try { rollbackAndClose(conn); - } catch (SQLException e) { // NOPMD + } catch (final SQLException e) { // NOPMD // quiet } } @@ -408,15 +409,15 @@ public final class DbUtils { public Logger getParentLogger() throws SQLFeatureNotSupportedException { if (parentLoggerSupported) { try { - Method method = adapted.getClass().getMethod("getParentLogger", new Class[0]); + final Method method = adapted.getClass().getMethod("getParentLogger", new Class[0]); return (Logger)method.invoke(adapted, new Object[0]); - } catch (NoSuchMethodException e) { + } catch (final NoSuchMethodException e) { parentLoggerSupported = false; throw new SQLFeatureNotSupportedException(e); - } catch (IllegalAccessException e) { + } catch (final IllegalAccessException e) { parentLoggerSupported = false; throw new SQLFeatureNotSupportedException(e); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { parentLoggerSupported = false; throw new SQLFeatureNotSupportedException(e); } http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/OutParameter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/OutParameter.java b/src/main/java/org/apache/commons/dbutils/OutParameter.java index e3996a1..93e00fb 100644 --- a/src/main/java/org/apache/commons/dbutils/OutParameter.java +++ b/src/main/java/org/apache/commons/dbutils/OutParameter.java @@ -113,7 +113,7 @@ public class OutParameter<T> { * statement. */ void setValue(final CallableStatement stmt, final int index) throws SQLException { - Object object = stmt.getObject(index); + final Object object = stmt.getObject(index); value = javaType.cast(object); } http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/QueryLoader.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/QueryLoader.java b/src/main/java/org/apache/commons/dbutils/QueryLoader.java index 2fd032c..a38e530 100644 --- a/src/main/java/org/apache/commons/dbutils/QueryLoader.java +++ b/src/main/java/org/apache/commons/dbutils/QueryLoader.java @@ -127,6 +127,7 @@ public class QueryLoader { // Copy to HashMap for better performance @SuppressWarnings({"rawtypes", "unchecked" }) // load() always creates <String,String> entries + final HashMap<String, String> hashMap = new HashMap(props); return hashMap; } http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/QueryRunner.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/QueryRunner.java b/src/main/java/org/apache/commons/dbutils/QueryRunner.java index f4f3f4b..b7fb46b 100644 --- a/src/main/java/org/apache/commons/dbutils/QueryRunner.java +++ b/src/main/java/org/apache/commons/dbutils/QueryRunner.java @@ -146,7 +146,7 @@ public class QueryRunner extends AbstractQueryRunner { * @since DbUtils 1.1 */ public int[] batch(final String sql, final Object[][] params) throws SQLException { - Connection conn = this.prepareConnection(); + final Connection conn = this.prepareConnection(); return this.batch(conn, true, sql, params); } @@ -191,7 +191,7 @@ public class QueryRunner extends AbstractQueryRunner { } rows = stmt.executeBatch(); - } catch (SQLException e) { + } catch (final SQLException e) { this.rethrow(e, sql, (Object[])params); } finally { close(stmt); @@ -282,7 +282,7 @@ public class QueryRunner extends AbstractQueryRunner { */ @Deprecated public <T> T query(final String sql, final Object param, final ResultSetHandler<T> rsh) throws SQLException { - Connection conn = this.prepareConnection(); + final Connection conn = this.prepareConnection(); return this.<T>query(conn, true, sql, rsh, new Object[]{param}); } @@ -305,7 +305,7 @@ public class QueryRunner extends AbstractQueryRunner { */ @Deprecated public <T> T query(final String sql, final Object[] params, final ResultSetHandler<T> rsh) throws SQLException { - Connection conn = this.prepareConnection(); + final Connection conn = this.prepareConnection(); return this.<T>query(conn, true, sql, rsh, params); } @@ -324,7 +324,7 @@ public class QueryRunner extends AbstractQueryRunner { * @throws SQLException if a database access error occurs */ public <T> T query(final String sql, final ResultSetHandler<T> rsh, final Object... params) throws SQLException { - Connection conn = this.prepareConnection(); + final Connection conn = this.prepareConnection(); return this.<T>query(conn, true, sql, rsh, params); } @@ -342,7 +342,7 @@ public class QueryRunner extends AbstractQueryRunner { * @throws SQLException if a database access error occurs */ public <T> T query(final String sql, final ResultSetHandler<T> rsh) throws SQLException { - Connection conn = this.prepareConnection(); + final Connection conn = this.prepareConnection(); return this.<T>query(conn, true, sql, rsh, (Object[]) null); } @@ -387,7 +387,7 @@ public class QueryRunner extends AbstractQueryRunner { rs = this.wrap(stmt.executeQuery()); result = rsh.handle(rs); - } catch (SQLException e) { + } catch (final SQLException e) { this.rethrow(e, sql, params); } finally { @@ -453,7 +453,7 @@ public class QueryRunner extends AbstractQueryRunner { * @return The number of rows updated. */ public int update(final String sql) throws SQLException { - Connection conn = this.prepareConnection(); + final Connection conn = this.prepareConnection(); return this.update(conn, true, sql, (Object[]) null); } @@ -471,7 +471,7 @@ public class QueryRunner extends AbstractQueryRunner { * @return The number of rows updated. */ public int update(final String sql, final Object param) throws SQLException { - Connection conn = this.prepareConnection(); + final Connection conn = this.prepareConnection(); return this.update(conn, true, sql, new Object[]{param}); } @@ -489,7 +489,7 @@ public class QueryRunner extends AbstractQueryRunner { * @return The number of rows updated. */ public int update(final String sql, final Object... params) throws SQLException { - Connection conn = this.prepareConnection(); + final Connection conn = this.prepareConnection(); return this.update(conn, true, sql, params); } @@ -524,7 +524,7 @@ public class QueryRunner extends AbstractQueryRunner { this.fillStatement(stmt, params); rows = stmt.executeUpdate(); - } catch (SQLException e) { + } catch (final SQLException e) { this.rethrow(e, sql, params); } finally { @@ -641,9 +641,9 @@ public class QueryRunner extends AbstractQueryRunner { stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); this.fillStatement(stmt, params); stmt.executeUpdate(); - ResultSet resultSet = stmt.getGeneratedKeys(); + final ResultSet resultSet = stmt.getGeneratedKeys(); generatedKeys = rsh.handle(resultSet); - } catch (SQLException e) { + } catch (final SQLException e) { this.rethrow(e, sql, params); } finally { close(stmt); @@ -731,10 +731,10 @@ public class QueryRunner extends AbstractQueryRunner { stmt.addBatch(); } stmt.executeBatch(); - ResultSet rs = stmt.getGeneratedKeys(); + final ResultSet rs = stmt.getGeneratedKeys(); generatedKeys = rsh.handle(rs); - } catch (SQLException e) { + } catch (final SQLException e) { this.rethrow(e, sql, (Object[])params); } finally { close(stmt); @@ -792,7 +792,7 @@ public class QueryRunner extends AbstractQueryRunner { * @return The number of rows updated. */ public int execute(final String sql, final Object... params) throws SQLException { - Connection conn = this.prepareConnection(); + final Connection conn = this.prepareConnection(); return this.execute(conn, true, sql, params); } @@ -845,7 +845,7 @@ public class QueryRunner extends AbstractQueryRunner { * @throws SQLException if a database access error occurs */ public <T> List<T> execute(final String sql, final ResultSetHandler<T> rsh, final Object... params) throws SQLException { - Connection conn = this.prepareConnection(); + final Connection conn = this.prepareConnection(); return this.execute(conn, true, sql, rsh, params); } @@ -883,7 +883,7 @@ public class QueryRunner extends AbstractQueryRunner { rows = stmt.getUpdateCount(); this.retrieveOutParameters(stmt, params); - } catch (SQLException e) { + } catch (final SQLException e) { this.rethrow(e, sql, params); } finally { @@ -928,7 +928,7 @@ public class QueryRunner extends AbstractQueryRunner { } CallableStatement stmt = null; - List<T> results = new LinkedList<>(); + final List<T> results = new LinkedList<>(); try { stmt = this.prepareCall(conn, sql); @@ -949,7 +949,7 @@ public class QueryRunner extends AbstractQueryRunner { } this.retrieveOutParameters(stmt, params); - } catch (SQLException e) { + } catch (final SQLException e) { this.rethrow(e, sql, params); } finally { http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java b/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java index a7ce7c9..025a2dd 100644 --- a/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java +++ b/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java @@ -73,7 +73,7 @@ public class ResultSetIterator implements Iterator<Object[]> { public boolean hasNext() { try { return !rs.isLast(); - } catch (SQLException e) { + } catch (final SQLException e) { rethrow(e); return false; } @@ -91,7 +91,7 @@ public class ResultSetIterator implements Iterator<Object[]> { try { rs.next(); return this.convert.toArray(rs); - } catch (SQLException e) { + } catch (final SQLException e) { rethrow(e); return null; } @@ -106,7 +106,7 @@ public class ResultSetIterator implements Iterator<Object[]> { public void remove() { try { this.rs.deleteRow(); - } catch (SQLException e) { + } catch (final SQLException e) { rethrow(e); } } http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java index 69e3a64..d694f30 100644 --- a/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java +++ b/src/main/java/org/apache/commons/dbutils/handlers/AbstractKeyedHandler.java @@ -48,7 +48,7 @@ public abstract class AbstractKeyedHandler<K, V> implements ResultSetHandler<Map */ @Override public Map<K, V> handle(final ResultSet rs) throws SQLException { - Map<K, V> result = createMap(); + final Map<K, V> result = createMap(); while (rs.next()) { result.put(createKey(rs), createRow(rs)); } http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java index d360155..6db0bb8 100644 --- a/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java +++ b/src/main/java/org/apache/commons/dbutils/handlers/AbstractListHandler.java @@ -43,7 +43,7 @@ public abstract class AbstractListHandler<T> implements ResultSetHandler<List<T> */ @Override public List<T> handle(final ResultSet rs) throws SQLException { - List<T> rows = new ArrayList<>(); + final List<T> rows = new ArrayList<>(); while (rs.next()) { rows.add(this.handleRow(rs)); } http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandler.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandler.java b/src/main/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandler.java index 3c83cb0..0c6a89e 100644 --- a/src/main/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandler.java +++ b/src/main/java/org/apache/commons/dbutils/handlers/properties/DatePropertyHandler.java @@ -49,8 +49,8 @@ public class DatePropertyHandler implements PropertyHandler { value = new java.sql.Time(((java.util.Date) value).getTime()); } else if ("java.sql.Timestamp".equals(targetType)) { - Timestamp tsValue = (Timestamp) value; - int nanos = tsValue.getNanos(); + final Timestamp tsValue = (Timestamp) value; + final int nanos = tsValue.getNanos(); value = new java.sql.Timestamp(tsValue.getTime()); ((Timestamp) value).setNanos(nanos); } http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java b/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java index 4ef433e..fa42f41 100644 --- a/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java +++ b/src/main/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSet.java @@ -83,12 +83,12 @@ public class SqlNullCheckedResultSet implements InvocationHandler { private static final String GET_NULL_PREFIX = "getNull"; static { - Method[] methods = SqlNullCheckedResultSet.class.getMethods(); + final Method[] methods = SqlNullCheckedResultSet.class.getMethods(); for (int i = 0; i < methods.length; i++) { - String methodName = methods[i].getName(); + final String methodName = methods[i].getName(); if (methodName.startsWith(GET_NULL_PREFIX)) { - String normalName = "get" + methodName.substring(GET_NULL_PREFIX.length()); + final String normalName = "get" + methodName.substring(GET_NULL_PREFIX.length()); nullMethods.put(normalName, methods[i]); } } @@ -221,7 +221,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler { if (this.nullBytes == null) { return null; } - byte[] copy = new byte[this.nullBytes.length]; + final byte[] copy = new byte[this.nullBytes.length]; System.arraycopy(this.nullBytes, 0, copy, 0, this.nullBytes.length); return copy; } @@ -382,9 +382,9 @@ public class SqlNullCheckedResultSet implements InvocationHandler { public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { - Object result = method.invoke(this.rs, args); + final Object result = method.invoke(this.rs, args); - Method nullMethod = nullMethods.get(method.getName()); + final Method nullMethod = nullMethods.get(method.getName()); // Check nullMethod != null first so that we don't call wasNull() // before a true getter method was invoked on the ResultSet. @@ -460,7 +460,7 @@ public class SqlNullCheckedResultSet implements InvocationHandler { * @param nullBytes the value */ public void setNullBytes(final byte[] nullBytes) { - byte[] copy = new byte[nullBytes.length]; + final byte[] copy = new byte[nullBytes.length]; System.arraycopy(nullBytes, 0, copy, 0, nullBytes.length); this.nullBytes = copy; } http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java b/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java index 6c0a769..f900feb 100644 --- a/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java +++ b/src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java @@ -73,7 +73,7 @@ public class AsyncQueryRunnerTest { // private void callGoodBatch(final Connection conn, final Object[][] params) throws Exception { when(meta.getParameterCount()).thenReturn(2); - Future<int[]> future = runner.batch(conn, "select * from blah where ? = ?", params); + final Future<int[]> future = runner.batch(conn, "select * from blah where ? = ?", params); future.get(); @@ -85,7 +85,7 @@ public class AsyncQueryRunnerTest { private void callGoodBatch(final Object[][] params) throws Exception { when(meta.getParameterCount()).thenReturn(2); - Future<int[]> future = runner.batch("select * from blah where ? = ?", params); + final Future<int[]> future = runner.batch("select * from blah where ? = ?", params); future.get(); @@ -97,7 +97,7 @@ public class AsyncQueryRunnerTest { @Test public void testGoodBatch() throws Exception { - String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; + final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; callGoodBatch(params); } @@ -106,7 +106,7 @@ public class AsyncQueryRunnerTest { @Test public void testGoodBatchPmdTrue() throws Exception { runner = new AsyncQueryRunner(dataSource, true, Executors.newFixedThreadPool(1)); - String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; + final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; callGoodBatch(params); } @@ -114,14 +114,14 @@ public class AsyncQueryRunnerTest { @Test public void testGoodBatchDefaultConstructor() throws Exception { runner = new AsyncQueryRunner(Executors.newFixedThreadPool(1)); - String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; + final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; callGoodBatch(conn, params); } @Test public void testNullParamsBatch() throws Exception { - String[][] params = new String[][] { { null, "unit" }, { "test", null } }; + final String[][] params = new String[][] { { null, "unit" }, { "test", null } }; callGoodBatch(params); } @@ -142,7 +142,7 @@ public class AsyncQueryRunnerTest { verify(stmt, times(1)).executeBatch(); verify(stmt, times(1)).close(); // make sure the statement is closed verify(conn, times(1)).close(); // make sure the connection is closed - } catch(Exception e) { + } catch(final Exception e) { caught = true; } @@ -153,21 +153,21 @@ public class AsyncQueryRunnerTest { @Test public void testTooFewParamsBatch() throws Exception { - String[][] params = new String[][] { { "unit" }, { "test" } }; + final String[][] params = new String[][] { { "unit" }, { "test" } }; callBatchWithException("select * from blah where ? = ?", params); } @Test public void testTooManyParamsBatch() throws Exception { - String[][] params = new String[][] { { "unit", "unit", "unit" }, { "test", "test", "test" } }; + final String[][] params = new String[][] { { "unit", "unit", "unit" }, { "test", "test", "test" } }; callBatchWithException("select * from blah where ? = ?", params); } @Test(expected=ExecutionException.class) public void testNullConnectionBatch() throws Exception { - String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; + final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; when(meta.getParameterCount()).thenReturn(2); when(dataSource.getConnection()).thenReturn(null); @@ -177,7 +177,7 @@ public class AsyncQueryRunnerTest { @Test(expected=ExecutionException.class) public void testNullSqlBatch() throws Exception { - String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; + final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; when(meta.getParameterCount()).thenReturn(2); @@ -193,7 +193,7 @@ public class AsyncQueryRunnerTest { @Test public void testAddBatchException() throws Exception { - String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; + final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; doThrow(new SQLException()).when(stmt).addBatch(); @@ -202,7 +202,7 @@ public class AsyncQueryRunnerTest { @Test public void testExecuteBatchException() throws Exception { - String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; + final String[][] params = new String[][] { { "unit", "unit" }, { "test", "test" } }; doThrow(new SQLException()).when(stmt).executeBatch(); @@ -282,7 +282,7 @@ public class AsyncQueryRunnerTest { verify(results, times(1)).close(); verify(stmt, times(1)).close(); // make sure we closed the statement verify(conn, times(1)).close(); // make sure we closed the connection - } catch(Exception e) { + } catch(final Exception e) { caught = true; } @@ -418,7 +418,7 @@ public class AsyncQueryRunnerTest { verify(stmt, times(1)).executeUpdate(); verify(stmt, times(1)).close(); // make sure we closed the statement verify(conn, times(1)).close(); // make sure we closed the connection - } catch(Exception e) { + } catch(final Exception e) { caught = true; } @@ -444,7 +444,7 @@ public class AsyncQueryRunnerTest { @Test public void testInsertUsesGivenQueryRunner() throws Exception { - QueryRunner mockQueryRunner = mock(QueryRunner.class + final QueryRunner mockQueryRunner = mock(QueryRunner.class , org.mockito.Mockito.withSettings().verboseLogging() // debug for Continuum ); runner = new AsyncQueryRunner(Executors.newSingleThreadExecutor(), mockQueryRunner); http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java b/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java index e37422f..f4b81a2 100644 --- a/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java +++ b/src/test/java/org/apache/commons/dbutils/BaseResultSetHandlerTest.java @@ -28,11 +28,11 @@ public final class BaseResultSetHandlerTest extends BaseTestCase { @Test public void handleWithoutExplicitResultSetInvocation() throws Exception { - Collection<Map<String, Object>> result = new ToMapCollectionHandler().handle(createMockResultSet()); + final Collection<Map<String, Object>> result = new ToMapCollectionHandler().handle(createMockResultSet()); assertFalse(result.isEmpty()); - for (Map<String, Object> current : result) { + for (final Map<String, Object> current : result) { assertTrue(current.containsKey("one")); assertTrue(current.containsKey("two")); assertTrue(current.containsKey("three")); @@ -51,10 +51,10 @@ public final class BaseResultSetHandlerTest extends BaseTestCase { @Override protected Collection<Map<String, Object>> handle() throws SQLException { - Collection<Map<String, Object>> result = new LinkedList<>(); + final Collection<Map<String, Object>> result = new LinkedList<>(); while (next()) { - Map<String, Object> current = new HashMap<>(); + final Map<String, Object> current = new HashMap<>(); for (int i = 1; i <= getMetaData().getColumnCount(); i++) { current.put(getMetaData().getColumnName(i), getObject(i)); http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java b/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java index 7c701cd..49458ea 100644 --- a/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java +++ b/src/test/java/org/apache/commons/dbutils/BasicRowProcessorTest.java @@ -92,7 +92,7 @@ public class BasicRowProcessorTest extends BaseTestCase { public void testToBeanList() throws SQLException, ParseException { - List<TestBean> list = processor.toBeanList(this.rs, TestBean.class); + final List<TestBean> list = processor.toBeanList(this.rs, TestBean.class); assertNotNull(list); assertEquals(ROWS, list.size()); @@ -141,9 +141,9 @@ public class BasicRowProcessorTest extends BaseTestCase { public void testToMapOrdering() throws SQLException { assertTrue(this.rs.next()); - Map<String, Object> m = processor.toMap(this.rs); + final Map<String, Object> m = processor.toMap(this.rs); - Iterator<String> itr = m.keySet().iterator(); + final Iterator<String> itr = m.keySet().iterator(); assertEquals("one", itr.next()); assertEquals("two", itr.next()); assertEquals("three", itr.next()); http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java index e1606e4..a1f6cea 100644 --- a/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java +++ b/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java @@ -101,29 +101,29 @@ public class BeanProcessorTest extends BaseTestCase { } public void testMapColumnToProperties() throws Exception { - String[] columnNames = { "test", "test", "three" }; - String[] columnLabels = { "one", "two", null }; - ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData( + final String[] columnNames = { "test", "test", "three" }; + final String[] columnLabels = { "one", "two", null }; + final ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData( new MockResultSetMetaData(columnNames, columnLabels)); - PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors(); + final PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors(); - int[] columns = beanProc.mapColumnsToProperties(rsmd, props); + final int[] columns = beanProc.mapColumnsToProperties(rsmd, props); for (int i = 1; i < columns.length; i++) { assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND); } } public void testMapColumnToPropertiesWithOverrides() throws Exception { - Map<String, String> columnToPropertyOverrides = new HashMap<>(); + final Map<String, String> columnToPropertyOverrides = new HashMap<>(); columnToPropertyOverrides.put("five", "four"); - BeanProcessor beanProc = new BeanProcessor(columnToPropertyOverrides); - String[] columnNames = { "test", "test", "three", "five" }; - String[] columnLabels = { "one", "two", null, null }; - ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData( + final BeanProcessor beanProc = new BeanProcessor(columnToPropertyOverrides); + final String[] columnNames = { "test", "test", "three", "five" }; + final String[] columnLabels = { "one", "two", null, null }; + final ResultSetMetaData rsmd = ProxyFactory.instance().createResultSetMetaData( new MockResultSetMetaData(columnNames, columnLabels)); - PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors(); + final PropertyDescriptor[] props = Introspector.getBeanInfo(MapColumnToPropertiesBean.class).getPropertyDescriptors(); - int[] columns = beanProc.mapColumnsToProperties(rsmd, props); + final int[] columns = beanProc.mapColumnsToProperties(rsmd, props); for (int i = 1; i < columns.length; i++) { assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND); } http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java b/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java index 78e9081..52b42d2 100644 --- a/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java +++ b/src/test/java/org/apache/commons/dbutils/DbUtilsTest.java @@ -1,285 +1,285 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.dbutils; - -import org.junit.Test; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.*; - -public class DbUtilsTest { - - @Test - public void closeNullConnection() throws Exception { - DbUtils.close((Connection) null); - } - - @Test - public void closeConnection() throws Exception { - Connection mockCon = mock(Connection.class); - DbUtils.close(mockCon); - verify(mockCon).close(); - } - - @Test - public void closeNullResultSet() throws Exception { - DbUtils.close((ResultSet) null); - } - - @Test - public void closeResultSet() throws Exception { - ResultSet mockResultSet = mock(ResultSet.class); - DbUtils.close(mockResultSet); - verify(mockResultSet).close(); - } - - @Test - public void closeNullStatement() throws Exception { - DbUtils.close((Statement) null); - } - - @Test - public void closeStatement() throws Exception { - Statement mockStatement = mock(Statement.class); - DbUtils.close(mockStatement); - verify(mockStatement).close(); - } - - @Test - public void closeQuietlyNullConnection() throws Exception { - DbUtils.closeQuietly((Connection) null); - } - - @Test - public void closeQuietlyConnection() throws Exception { - Connection mockConnection = mock(Connection.class); - DbUtils.closeQuietly(mockConnection); - verify(mockConnection).close(); - } - - @Test - public void closeQuietlyConnectionThrowingException() throws Exception { - Connection mockConnection = mock(Connection.class); - doThrow(SQLException.class).when(mockConnection).close(); - DbUtils.closeQuietly(mockConnection); - } - - @Test - public void closeQuietlyNullResultSet() throws Exception { - DbUtils.closeQuietly((ResultSet) null); - } - - @Test - public void closeQuietlyResultSet() throws Exception { - ResultSet mockResultSet = mock(ResultSet.class); - DbUtils.closeQuietly(mockResultSet); - verify(mockResultSet).close(); - } - - @Test - public void closeQuietlyResultSetThrowingException() throws Exception { - ResultSet mockResultSet = mock(ResultSet.class); - doThrow(SQLException.class).when(mockResultSet).close(); - DbUtils.closeQuietly(mockResultSet); - } - - @Test - public void closeQuietlyNullStatement() throws Exception { - DbUtils.closeQuietly((Statement) null); - } - - @Test - public void closeQuietlyStatement() throws Exception { - Statement mockStatement = mock(Statement.class); - DbUtils.closeQuietly(mockStatement); - verify(mockStatement).close(); - } - - @Test - public void closeQuietlyStatementThrowingException() throws Exception { - Statement mockStatement = mock(Statement.class); - doThrow(SQLException.class).when(mockStatement).close(); - DbUtils.closeQuietly(mockStatement); - } - - @Test - public void closeQuietlyConnectionResultSetStatement() throws Exception { - Connection mockConnection = mock(Connection.class); - ResultSet mockResultSet = mock(ResultSet.class); - Statement mockStatement = mock(Statement.class); - DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet); - verify(mockConnection).close(); - verify(mockResultSet).close(); - verify(mockStatement).close(); - } - - @Test - public void closeQuietlyConnectionThrowingExceptionResultSetStatement() throws Exception { - Connection mockConnection = mock(Connection.class); - doThrow(SQLException.class).when(mockConnection).close(); - ResultSet mockResultSet = mock(ResultSet.class); - Statement mockStatement = mock(Statement.class); - DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet); - verify(mockConnection).close(); - verify(mockResultSet).close(); - verify(mockStatement).close(); - } - - @Test - public void closeQuietlyConnectionResultSetThrowingExceptionStatement() throws Exception { - Connection mockConnection = mock(Connection.class); - ResultSet mockResultSet = mock(ResultSet.class); - doThrow(SQLException.class).when(mockResultSet).close(); - Statement mockStatement = mock(Statement.class); - DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet); - verify(mockConnection).close(); - verify(mockResultSet).close(); - verify(mockStatement).close(); - } - - @Test - public void closeQuietlyConnectionResultSetStatementThrowingException() throws Exception { - Connection mockConnection = mock(Connection.class); - ResultSet mockResultSet = mock(ResultSet.class); - Statement mockStatement = mock(Statement.class); - doThrow(SQLException.class).when(mockStatement).close(); - DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet); - verify(mockConnection).close(); - verify(mockResultSet).close(); - verify(mockStatement).close(); - } - - @Test - public void commitAndClose() throws Exception { - Connection mockConnection = mock(Connection.class); - DbUtils.commitAndClose(mockConnection); - verify(mockConnection).commit(); - verify(mockConnection).close(); - } - - @Test - public void commitAndCloseWithException() throws Exception { - Connection mockConnection = mock(Connection.class); - doThrow(SQLException.class).when(mockConnection).commit(); - try { - DbUtils.commitAndClose(mockConnection); - fail("DbUtils.commitAndClose() swallowed SQLEception!"); - } catch (SQLException e) { - // we expect this exception - } - verify(mockConnection).close(); - } - - @Test - public void commitAndCloseQuietly() throws Exception { - Connection mockConnection = mock(Connection.class); - DbUtils.commitAndClose(mockConnection); - verify(mockConnection).commit(); - verify(mockConnection).close(); - } - - @Test - public void commitAndCloseQuietlyWithException() throws Exception { - Connection mockConnection = mock(Connection.class); - doThrow(SQLException.class).when(mockConnection).close(); - DbUtils.commitAndCloseQuietly(mockConnection); - verify(mockConnection).commit(); - verify(mockConnection).close(); - } - - @Test - public void rollbackNull() throws Exception { - DbUtils.rollback(null); - } - - @Test - public void rollback() throws Exception { - Connection mockConnection = mock(Connection.class); - DbUtils.rollback(mockConnection); - verify(mockConnection).rollback(); - } - - @Test - public void rollbackAndCloseNull() throws Exception { - DbUtils.rollbackAndClose(null); - } - - @Test - public void rollbackAndClose() throws Exception { - Connection mockConnection = mock(Connection.class); - DbUtils.rollbackAndClose(mockConnection); - verify(mockConnection).rollback(); - verify(mockConnection).close(); - } - - @Test - public void rollbackAndCloseWithException() throws Exception { - Connection mockConnection = mock(Connection.class); - doThrow(SQLException.class).when(mockConnection).rollback(); - try { - DbUtils.rollbackAndClose(mockConnection); - fail("DbUtils.rollbackAndClose() swallowed SQLException!"); - } catch (SQLException e) { - // we expect this exeption - } - verify(mockConnection).rollback(); - verify(mockConnection).close(); - } - - @Test - public void rollbackAndCloseQuietlyNull() throws Exception { - DbUtils.rollbackAndCloseQuietly(null); - } - - @Test - public void rollbackAndCloseQuietly() throws Exception { - Connection mockConnection = mock(Connection.class); - DbUtils.rollbackAndCloseQuietly(mockConnection); - verify(mockConnection).rollback(); - verify(mockConnection).close(); - } - - @Test - public void rollbackAndCloseQuietlyWithException() throws Exception { - Connection mockConnection = mock(Connection.class); - doThrow(SQLException.class).when(mockConnection).rollback(); - DbUtils.rollbackAndCloseQuietly(mockConnection); - verify(mockConnection).rollback(); - verify(mockConnection).close(); - } - - @Test - public void testLoadDriverReturnsFalse() { - - assertFalse(DbUtils.loadDriver("")); - - } - - @Test - public void testCommitAndCloseQuietlyWithNullDoesNotThrowAnSQLException() { - - DbUtils.commitAndCloseQuietly(null); - - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.dbutils; + +import org.junit.Test; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.*; + +public class DbUtilsTest { + + @Test + public void closeNullConnection() throws Exception { + DbUtils.close((Connection) null); + } + + @Test + public void closeConnection() throws Exception { + final Connection mockCon = mock(Connection.class); + DbUtils.close(mockCon); + verify(mockCon).close(); + } + + @Test + public void closeNullResultSet() throws Exception { + DbUtils.close((ResultSet) null); + } + + @Test + public void closeResultSet() throws Exception { + final ResultSet mockResultSet = mock(ResultSet.class); + DbUtils.close(mockResultSet); + verify(mockResultSet).close(); + } + + @Test + public void closeNullStatement() throws Exception { + DbUtils.close((Statement) null); + } + + @Test + public void closeStatement() throws Exception { + final Statement mockStatement = mock(Statement.class); + DbUtils.close(mockStatement); + verify(mockStatement).close(); + } + + @Test + public void closeQuietlyNullConnection() throws Exception { + DbUtils.closeQuietly((Connection) null); + } + + @Test + public void closeQuietlyConnection() throws Exception { + final Connection mockConnection = mock(Connection.class); + DbUtils.closeQuietly(mockConnection); + verify(mockConnection).close(); + } + + @Test + public void closeQuietlyConnectionThrowingException() throws Exception { + final Connection mockConnection = mock(Connection.class); + doThrow(SQLException.class).when(mockConnection).close(); + DbUtils.closeQuietly(mockConnection); + } + + @Test + public void closeQuietlyNullResultSet() throws Exception { + DbUtils.closeQuietly((ResultSet) null); + } + + @Test + public void closeQuietlyResultSet() throws Exception { + final ResultSet mockResultSet = mock(ResultSet.class); + DbUtils.closeQuietly(mockResultSet); + verify(mockResultSet).close(); + } + + @Test + public void closeQuietlyResultSetThrowingException() throws Exception { + final ResultSet mockResultSet = mock(ResultSet.class); + doThrow(SQLException.class).when(mockResultSet).close(); + DbUtils.closeQuietly(mockResultSet); + } + + @Test + public void closeQuietlyNullStatement() throws Exception { + DbUtils.closeQuietly((Statement) null); + } + + @Test + public void closeQuietlyStatement() throws Exception { + final Statement mockStatement = mock(Statement.class); + DbUtils.closeQuietly(mockStatement); + verify(mockStatement).close(); + } + + @Test + public void closeQuietlyStatementThrowingException() throws Exception { + final Statement mockStatement = mock(Statement.class); + doThrow(SQLException.class).when(mockStatement).close(); + DbUtils.closeQuietly(mockStatement); + } + + @Test + public void closeQuietlyConnectionResultSetStatement() throws Exception { + final Connection mockConnection = mock(Connection.class); + final ResultSet mockResultSet = mock(ResultSet.class); + final Statement mockStatement = mock(Statement.class); + DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet); + verify(mockConnection).close(); + verify(mockResultSet).close(); + verify(mockStatement).close(); + } + + @Test + public void closeQuietlyConnectionThrowingExceptionResultSetStatement() throws Exception { + final Connection mockConnection = mock(Connection.class); + doThrow(SQLException.class).when(mockConnection).close(); + final ResultSet mockResultSet = mock(ResultSet.class); + final Statement mockStatement = mock(Statement.class); + DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet); + verify(mockConnection).close(); + verify(mockResultSet).close(); + verify(mockStatement).close(); + } + + @Test + public void closeQuietlyConnectionResultSetThrowingExceptionStatement() throws Exception { + final Connection mockConnection = mock(Connection.class); + final ResultSet mockResultSet = mock(ResultSet.class); + doThrow(SQLException.class).when(mockResultSet).close(); + final Statement mockStatement = mock(Statement.class); + DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet); + verify(mockConnection).close(); + verify(mockResultSet).close(); + verify(mockStatement).close(); + } + + @Test + public void closeQuietlyConnectionResultSetStatementThrowingException() throws Exception { + final Connection mockConnection = mock(Connection.class); + final ResultSet mockResultSet = mock(ResultSet.class); + final Statement mockStatement = mock(Statement.class); + doThrow(SQLException.class).when(mockStatement).close(); + DbUtils.closeQuietly(mockConnection, mockStatement, mockResultSet); + verify(mockConnection).close(); + verify(mockResultSet).close(); + verify(mockStatement).close(); + } + + @Test + public void commitAndClose() throws Exception { + final Connection mockConnection = mock(Connection.class); + DbUtils.commitAndClose(mockConnection); + verify(mockConnection).commit(); + verify(mockConnection).close(); + } + + @Test + public void commitAndCloseWithException() throws Exception { + final Connection mockConnection = mock(Connection.class); + doThrow(SQLException.class).when(mockConnection).commit(); + try { + DbUtils.commitAndClose(mockConnection); + fail("DbUtils.commitAndClose() swallowed SQLEception!"); + } catch (final SQLException e) { + // we expect this exception + } + verify(mockConnection).close(); + } + + @Test + public void commitAndCloseQuietly() throws Exception { + final Connection mockConnection = mock(Connection.class); + DbUtils.commitAndClose(mockConnection); + verify(mockConnection).commit(); + verify(mockConnection).close(); + } + + @Test + public void commitAndCloseQuietlyWithException() throws Exception { + final Connection mockConnection = mock(Connection.class); + doThrow(SQLException.class).when(mockConnection).close(); + DbUtils.commitAndCloseQuietly(mockConnection); + verify(mockConnection).commit(); + verify(mockConnection).close(); + } + + @Test + public void rollbackNull() throws Exception { + DbUtils.rollback(null); + } + + @Test + public void rollback() throws Exception { + final Connection mockConnection = mock(Connection.class); + DbUtils.rollback(mockConnection); + verify(mockConnection).rollback(); + } + + @Test + public void rollbackAndCloseNull() throws Exception { + DbUtils.rollbackAndClose(null); + } + + @Test + public void rollbackAndClose() throws Exception { + final Connection mockConnection = mock(Connection.class); + DbUtils.rollbackAndClose(mockConnection); + verify(mockConnection).rollback(); + verify(mockConnection).close(); + } + + @Test + public void rollbackAndCloseWithException() throws Exception { + final Connection mockConnection = mock(Connection.class); + doThrow(SQLException.class).when(mockConnection).rollback(); + try { + DbUtils.rollbackAndClose(mockConnection); + fail("DbUtils.rollbackAndClose() swallowed SQLException!"); + } catch (final SQLException e) { + // we expect this exeption + } + verify(mockConnection).rollback(); + verify(mockConnection).close(); + } + + @Test + public void rollbackAndCloseQuietlyNull() throws Exception { + DbUtils.rollbackAndCloseQuietly(null); + } + + @Test + public void rollbackAndCloseQuietly() throws Exception { + final Connection mockConnection = mock(Connection.class); + DbUtils.rollbackAndCloseQuietly(mockConnection); + verify(mockConnection).rollback(); + verify(mockConnection).close(); + } + + @Test + public void rollbackAndCloseQuietlyWithException() throws Exception { + final Connection mockConnection = mock(Connection.class); + doThrow(SQLException.class).when(mockConnection).rollback(); + DbUtils.rollbackAndCloseQuietly(mockConnection); + verify(mockConnection).rollback(); + verify(mockConnection).close(); + } + + @Test + public void testLoadDriverReturnsFalse() { + + assertFalse(DbUtils.loadDriver("")); + + } + + @Test + public void testCommitAndCloseQuietlyWithNullDoesNotThrowAnSQLException() { + + DbUtils.commitAndCloseQuietly(null); + + } + +} http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java index 24a5639..95cf5a4 100644 --- a/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java +++ b/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java @@ -55,7 +55,7 @@ public class GenerousBeanProcessorTest { when(metaData.getColumnLabel(2)).thenReturn("one"); when(metaData.getColumnLabel(3)).thenReturn("two"); - int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors); + final int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors); assertNotNull(ret); assertEquals(4, ret.length); @@ -74,7 +74,7 @@ public class GenerousBeanProcessorTest { when(metaData.getColumnLabel(2)).thenReturn("One"); when(metaData.getColumnLabel(3)).thenReturn("tWO"); - int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors); + final int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors); assertNotNull(ret); assertEquals(4, ret.length); @@ -93,7 +93,7 @@ public class GenerousBeanProcessorTest { when(metaData.getColumnLabel(2)).thenReturn("o_n_e"); when(metaData.getColumnLabel(3)).thenReturn("t_w_o"); - int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors); + final int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors); assertNotNull(ret); assertEquals(4, ret.length); @@ -113,7 +113,7 @@ public class GenerousBeanProcessorTest { when(metaData.getColumnLabel(2)).thenReturn("One"); when(metaData.getColumnLabel(3)).thenReturn("tWO"); - int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors); + final int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors); assertNotNull(ret); assertEquals(2, ret.length); http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/e2c137f9/src/test/java/org/apache/commons/dbutils/MockResultSet.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/dbutils/MockResultSet.java b/src/test/java/org/apache/commons/dbutils/MockResultSet.java index c89b5bd..8815bd8 100644 --- a/src/test/java/org/apache/commons/dbutils/MockResultSet.java +++ b/src/test/java/org/apache/commons/dbutils/MockResultSet.java @@ -63,7 +63,7 @@ public class MockResultSet implements InvocationHandler { super(); this.metaData = metaData; if (rows == null) { - List<Object[]> empty = Collections.emptyList(); + final List<Object[]> empty = Collections.emptyList(); this.iter = empty.iterator(); } else { this.iter = Arrays.asList(rows).iterator(); @@ -98,7 +98,7 @@ public class MockResultSet implements InvocationHandler { */ private int columnNameToIndex(final String columnName) throws SQLException { for (int i = 0; i < this.currentRow.length; i++) { - int c = i + 1; + final int c = i + 1; if (this.metaData.getColumnName(c).equalsIgnoreCase(columnName)) { return c; } @@ -113,7 +113,7 @@ public class MockResultSet implements InvocationHandler { * @throws SQLException if a database access error occurs */ protected Object getBoolean(final int columnIndex) throws SQLException { - Object obj = this.currentRow[columnIndex - 1]; + final Object obj = this.currentRow[columnIndex - 1]; this.setWasNull(obj); try { @@ -121,7 +121,7 @@ public class MockResultSet implements InvocationHandler { ? Boolean.FALSE : Boolean.valueOf(obj.toString()); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { throw new SQLException(e.getMessage()); } } @@ -132,7 +132,7 @@ public class MockResultSet implements InvocationHandler { * @throws SQLException if a database access error occurs */ protected Object getByte(final int columnIndex) throws SQLException { - Object obj = this.currentRow[columnIndex - 1]; + final Object obj = this.currentRow[columnIndex - 1]; this.setWasNull(obj); try { @@ -140,7 +140,7 @@ public class MockResultSet implements InvocationHandler { ? Byte.valueOf((byte) 0) : Byte.valueOf(obj.toString()); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { throw new SQLException(e.getMessage()); } } @@ -151,7 +151,7 @@ public class MockResultSet implements InvocationHandler { * @throws SQLException if a database access error occurs */ protected Object getDouble(final int columnIndex) throws SQLException { - Object obj = this.currentRow[columnIndex - 1]; + final Object obj = this.currentRow[columnIndex - 1]; this.setWasNull(obj); try { @@ -159,7 +159,7 @@ public class MockResultSet implements InvocationHandler { ? new Double(0) : Double.valueOf(obj.toString()); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { throw new SQLException(e.getMessage()); } } @@ -170,13 +170,13 @@ public class MockResultSet implements InvocationHandler { * @throws SQLException if a database access error occurs */ protected Object getFloat(final int columnIndex) throws SQLException { - Object obj = this.currentRow[columnIndex - 1]; + final Object obj = this.currentRow[columnIndex - 1]; this.setWasNull(obj); try { return (obj == null) ? new Float(0) : Float.valueOf(obj.toString()); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { throw new SQLException(e.getMessage()); } } @@ -187,7 +187,7 @@ public class MockResultSet implements InvocationHandler { * @throws SQLException if a database access error occurs */ protected Object getInt(final int columnIndex) throws SQLException { - Object obj = this.currentRow[columnIndex - 1]; + final Object obj = this.currentRow[columnIndex - 1]; this.setWasNull(obj); try { @@ -195,7 +195,7 @@ public class MockResultSet implements InvocationHandler { ? Integer.valueOf(0) : Integer.valueOf(obj.toString()); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { throw new SQLException(e.getMessage()); } } @@ -206,13 +206,13 @@ public class MockResultSet implements InvocationHandler { * @throws SQLException if a database access error occurs */ protected Object getLong(final int columnIndex) throws SQLException { - Object obj = this.currentRow[columnIndex - 1]; + final Object obj = this.currentRow[columnIndex - 1]; this.setWasNull(obj); try { return (obj == null) ? Long.valueOf(0) : Long.valueOf(obj.toString()); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { throw new SQLException(e.getMessage()); } } @@ -230,7 +230,7 @@ public class MockResultSet implements InvocationHandler { * @throws SQLException if a database access error occurs */ protected Object getObject(final int columnIndex) throws SQLException { - Object obj = this.currentRow[columnIndex - 1]; + final Object obj = this.currentRow[columnIndex - 1]; this.setWasNull(obj); return obj; } @@ -241,7 +241,7 @@ public class MockResultSet implements InvocationHandler { * @throws SQLException if a database access error occurs */ protected Object getShort(final int columnIndex) throws SQLException { - Object obj = this.currentRow[columnIndex - 1]; + final Object obj = this.currentRow[columnIndex - 1]; this.setWasNull(obj); try { @@ -249,7 +249,7 @@ public class MockResultSet implements InvocationHandler { ? Short.valueOf((short) 0) : Short.valueOf(obj.toString()); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { throw new SQLException(e.getMessage()); } } @@ -260,7 +260,7 @@ public class MockResultSet implements InvocationHandler { * @throws SQLException if a database access error occurs */ protected String getString(final int columnIndex) throws SQLException { - Object obj = this.getObject(columnIndex); + final Object obj = this.getObject(columnIndex); this.setWasNull(obj); return (obj == null) ? null : obj.toString(); } @@ -269,7 +269,7 @@ public class MockResultSet implements InvocationHandler { public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { - String methodName = method.getName(); + final String methodName = method.getName(); if (methodName.equals("getMetaData")) { return this.getMetaData();
