You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/03/05 19:14:37 UTC
[commons-dbutils] branch master updated (453f2fc -> d81b49a)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbutils.git.
from 453f2fc Fix Checkstyle suppressions DTD link.
new fc2eaed Typo.
new 486e524 Add SpotBugs exclusion.
new d81b49a No need to nest in else.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
sb-excludes.xml | 8 +++++++-
.../org/apache/commons/dbutils/BeanProcessor.java | 5 ++---
.../handlers/properties/DatePropertyHandler.java | 4 ++--
.../org/apache/commons/dbutils/MockResultSet.java | 12 ++++++-----
.../commons/dbutils/MockResultSetMetaData.java | 18 +++++++++-------
.../wrappers/SqlNullCheckedResultSetTest.java | 24 ++++++++++++++--------
6 files changed, 44 insertions(+), 27 deletions(-)
[commons-dbutils] 01/03: Typo.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbutils.git
commit fc2eaed5c97de3d2ce8d11224b4710a3acda352b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Mar 5 14:12:13 2021 -0500
Typo.
---
sb-excludes.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sb-excludes.xml b/sb-excludes.xml
index 290a7c7..36e7de5 100644
--- a/sb-excludes.xml
+++ b/sb-excludes.xml
@@ -28,7 +28,7 @@
<Method name="printWarnings" />
<Bug pattern="DM_DEFAULT_ENCODING" />
</Match>
- <!-- The javadocs state and the called code shows that null can be returned. -->
+ <!-- The Javadocs state and the called code shows that null can be returned. -->
<Match>
<Class name="org.apache.commons.dbutils.QueryLoader" />
<Method name="loadQueries" />
[commons-dbutils] 03/03: No need to nest in else.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbutils.git
commit d81b49ad9c93766e13f3345c7137c1b89700148d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Mar 5 14:14:33 2021 -0500
No need to nest in else.
---
.../org/apache/commons/dbutils/BeanProcessor.java | 5 ++---
.../handlers/properties/DatePropertyHandler.java | 4 ++--
.../org/apache/commons/dbutils/MockResultSet.java | 12 ++++++-----
.../commons/dbutils/MockResultSetMetaData.java | 18 +++++++++-------
.../wrappers/SqlNullCheckedResultSetTest.java | 24 ++++++++++++++--------
5 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
index 7f76690..53c43eb 100644
--- a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
+++ b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java
@@ -306,14 +306,13 @@ public class BeanProcessor {
}
// Don't call setter if the value object isn't the right type
- if (this.isCompatibleType(value, firstParam)) {
- setter.invoke(target, value);
- } else {
+ if (!this.isCompatibleType(value, firstParam)) {
throw new SQLException(
"Cannot set " + prop.getName() + ": incompatible types, cannot convert "
+ value.getClass().getName() + " to " + firstParam.getName());
// value cannot be null here because isCompatibleType allows null
}
+ setter.invoke(target, value);
} catch (final IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
throw new SQLException(
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 9f9e491..7360ed0 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
@@ -32,10 +32,10 @@ public class DatePropertyHandler implements PropertyHandler {
final String targetType = parameter.getName();
if ("java.sql.Date".equals(targetType)) {
return true;
- } else
+ }
if ("java.sql.Time".equals(targetType)) {
return true;
- } else
+ }
if ("java.sql.Timestamp".equals(targetType)
&& !Timestamp.class.isInstance(value)) {
return true;
diff --git a/src/test/java/org/apache/commons/dbutils/MockResultSet.java b/src/test/java/org/apache/commons/dbutils/MockResultSet.java
index 537d4a3..66ad48e 100644
--- a/src/test/java/org/apache/commons/dbutils/MockResultSet.java
+++ b/src/test/java/org/apache/commons/dbutils/MockResultSet.java
@@ -82,12 +82,12 @@ public class MockResultSet implements InvocationHandler {
if (args[0] instanceof Integer) {
return ((Integer) args[0]).intValue();
- } else if (args[0] instanceof String) {
+ }
+ if (args[0] instanceof String) {
return this.columnNameToIndex((String) args[0]);
- } else {
- throw new SQLException(args[0] + " must be Integer or String");
}
+ throw new SQLException(args[0] + " must be Integer or String");
}
/**
@@ -273,10 +273,12 @@ public class MockResultSet implements InvocationHandler {
if (methodName.equals("getMetaData")) {
return this.getMetaData();
- } else if (methodName.equals("next")) {
+ }
+ if (methodName.equals("next")) {
return this.next();
- } else if (methodName.equals("previous")) {
+ }
+ if (methodName.equals("previous")) {
} else if (methodName.equals("close")) {
diff --git a/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java b/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
index dbcbe0d..04f0737 100644
--- a/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
+++ b/src/test/java/org/apache/commons/dbutils/MockResultSetMetaData.java
@@ -65,29 +65,33 @@ public class MockResultSetMetaData implements InvocationHandler {
if (methodName.equals("getColumnCount")) {
return Integer.valueOf(this.columnNames.length);
- } else if (
+ }
+ if (
methodName.equals("getColumnName")) {
final int col = ((Integer) args[0]).intValue() - 1;
return this.columnNames[col];
- } else if (
+ }
+ if (
methodName.equals("getColumnLabel")) {
final int col = ((Integer) args[0]).intValue() - 1;
return this.columnLabels[col];
- } else if (methodName.equals("hashCode")) {
+ }
+ if (methodName.equals("hashCode")) {
return Integer.valueOf(System.identityHashCode(proxy));
- } else if (methodName.equals("toString")) {
+ }
+ if (methodName.equals("toString")) {
return "MockResultSetMetaData " + System.identityHashCode(proxy);
- } else if (methodName.equals("equals")) {
+ }
+ if (methodName.equals("equals")) {
return Boolean.valueOf(proxy == args[0]);
- } else {
- throw new UnsupportedOperationException("Unsupported method: " + methodName);
}
+ throw new UnsupportedOperationException("Unsupported method: " + methodName);
}
}
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 b9e65fa..0269fe2 100644
--- a/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
+++ b/src/test/java/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
@@ -853,30 +853,36 @@ class SqlNullUncheckedMockResultSet implements InvocationHandler {
if (method.getName().equals("wasNull")) {
return Boolean.TRUE;
- } else if (returnType.equals(Boolean.TYPE)) {
+ }
+ if (returnType.equals(Boolean.TYPE)) {
return Boolean.FALSE;
- } else if (returnType.equals(Integer.TYPE)) {
+ }
+ if (returnType.equals(Integer.TYPE)) {
return Integer.valueOf(0);
- } else if (returnType.equals(Short.TYPE)) {
+ }
+ if (returnType.equals(Short.TYPE)) {
return Short.valueOf((short) 0);
- } else if (returnType.equals(Double.TYPE)) {
+ }
+ if (returnType.equals(Double.TYPE)) {
return new Double(0);
- } else if (returnType.equals(Long.TYPE)) {
+ }
+ if (returnType.equals(Long.TYPE)) {
return Long.valueOf(0);
- } else if (returnType.equals(Byte.TYPE)) {
+ }
+ if (returnType.equals(Byte.TYPE)) {
return Byte.valueOf((byte) 0);
- } else if (returnType.equals(Float.TYPE)) {
+ }
+ if (returnType.equals(Float.TYPE)) {
return new Float(0);
- } else {
- return null;
}
+ return null;
}
}
[commons-dbutils] 02/03: Add SpotBugs exclusion.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbutils.git
commit 486e524fd884ec296c84eb6c944a7b06e7dd5468
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Mar 5 14:14:26 2021 -0500
Add SpotBugs exclusion.
---
sb-excludes.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sb-excludes.xml b/sb-excludes.xml
index 36e7de5..38edc9b 100644
--- a/sb-excludes.xml
+++ b/sb-excludes.xml
@@ -34,4 +34,10 @@
<Method name="loadQueries" />
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
</Match>
+ <!-- This method returns a boolean indicating status. -->
+ <Match>
+ <Class name="org.apache.commons.dbutils.DbUtils" />
+ <Method name="loadDriver" />
+ <Bug pattern="REC_CATCH_EXCEPTION" />
+ </Match>
</FindBugsFilter>
\ No newline at end of file