From 39a6a8342428b652ed837e8e49a5f56cc8fdbb9e Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Fri, 27 Oct 2023 09:47:00 -0400 Subject: [PATCH] Don't initialize an instance or static variable to its default value --- src/conf/checkstyle/checkstyle.xml | 1 + .../apache/commons/dbutils/AbstractQueryRunner.java | 2 +- .../java/org/apache/commons/dbutils/OutParameter.java | 2 +- .../java/org/apache/commons/dbutils/BaseTestCase.java | 4 ++-- .../java/org/apache/commons/dbutils/MockResultSet.java | 4 ++-- src/test/java/org/apache/commons/dbutils/TestBean.java | 10 +++++----- .../dbutils/wrappers/SqlNullCheckedResultSetTest.java | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/conf/checkstyle/checkstyle.xml b/src/conf/checkstyle/checkstyle.xml index 41c5c77d..ab3bcc26 100644 --- a/src/conf/checkstyle/checkstyle.xml +++ b/src/conf/checkstyle/checkstyle.xml @@ -59,6 +59,7 @@ + diff --git a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java index c00fbe8f..b1bb78f6 100644 --- a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java +++ b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java @@ -44,7 +44,7 @@ public abstract class AbstractQueryRunner { * Is {@link ParameterMetaData#getParameterType(int)} broken (have we tried * it yet)? */ - private volatile boolean pmdKnownBroken = false; + private volatile boolean pmdKnownBroken; /** * The DataSource to retrieve connections from. diff --git a/src/main/java/org/apache/commons/dbutils/OutParameter.java b/src/main/java/org/apache/commons/dbutils/OutParameter.java index 04894522..5f8a6631 100644 --- a/src/main/java/org/apache/commons/dbutils/OutParameter.java +++ b/src/main/java/org/apache/commons/dbutils/OutParameter.java @@ -36,7 +36,7 @@ public class OutParameter { private final int sqlType; private final Class javaType; - private T value = null; + private T value; /** * Construct an {@code OutParameter} for the given JDBC SQL type and diff --git a/src/test/java/org/apache/commons/dbutils/BaseTestCase.java b/src/test/java/org/apache/commons/dbutils/BaseTestCase.java index 63a7adba..bb7f7f0f 100644 --- a/src/test/java/org/apache/commons/dbutils/BaseTestCase.java +++ b/src/test/java/org/apache/commons/dbutils/BaseTestCase.java @@ -103,12 +103,12 @@ public class BaseTestCase extends TestCase { /** * The ResultSet all test methods will use. */ - protected ResultSet rs = null; + protected ResultSet rs; /** * A ResultSet with 0 rows. */ - protected ResultSet emptyResultSet = null; + protected ResultSet emptyResultSet; /** * Creates a freshly initialized ResultSet. diff --git a/src/test/java/org/apache/commons/dbutils/MockResultSet.java b/src/test/java/org/apache/commons/dbutils/MockResultSet.java index 55256aeb..46be5428 100644 --- a/src/test/java/org/apache/commons/dbutils/MockResultSet.java +++ b/src/test/java/org/apache/commons/dbutils/MockResultSet.java @@ -48,9 +48,9 @@ public static ResultSet create(final ResultSetMetaData metaData, private Object[] currentRow = null; - private Iterator iter = null; + private Iterator iter; - private ResultSetMetaData metaData = null; + private ResultSetMetaData metaData; private Boolean wasNull = Boolean.FALSE; diff --git a/src/test/java/org/apache/commons/dbutils/TestBean.java b/src/test/java/org/apache/commons/dbutils/TestBean.java index b7200aaa..83fe007f 100644 --- a/src/test/java/org/apache/commons/dbutils/TestBean.java +++ b/src/test/java/org/apache/commons/dbutils/TestBean.java @@ -27,17 +27,17 @@ public enum Ordinal { } - private String one = null; + private String one; - private String two = null; + private String two; - private Ordinal three = null; + private Ordinal three; - private int intTest = 0; + private int intTest; private Integer integerTest = Integer.valueOf(0); - // UNUSED private Timestamp timestamp = null; + // UNUSED private Timestamp timestamp; private String doNotSet = "not set"; diff --git a/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java b/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java index 6a36d037..ddba4604 100644 --- a/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java +++ b/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java @@ -230,7 +230,7 @@ private static void assertArrayEquals(final byte[] expected, final byte[] actual } } - private SqlNullCheckedResultSet rs2 = null; + private SqlNullCheckedResultSet rs2; /** * Sets up instance variables required by this test case.