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 2023/08/01 14:53:45 UTC
[commons-dbutils] 10/15: AbstractQueryRunner.fillStatementWithBean(PreparedStatement, Object, String...) now throws IllegalStateException instead of RuntimeException.
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 cb9d633be82e948dc9861978fcb241e30aebb6cb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Aug 1 10:32:03 2023 -0400
AbstractQueryRunner.fillStatementWithBean(PreparedStatement, Object,
String...) now throws IllegalStateException instead of RuntimeException.
---
src/changes/changes.xml | 3 +++
.../java/org/apache/commons/dbutils/AbstractQueryRunner.java | 12 ++++--------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 38571c9..bf4cd7f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -78,6 +78,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" due-to="Gary Gregory" type="fix">
ResultSet not closed in QueryRunner.insertBatch(Connection, String, ResultSetHandler, Object[][]).
</action>
+ <action dev="ggregory" due-to="Gary Gregory" type="fix">
+ AbstractQueryRunner.fillStatementWithBean(PreparedStatement, Object, String...) now throws IllegalStateException instead of RuntimeException.
+ </action>
<!-- ADD -->
<action dev="thecarlhall" type="add" issue="PR/9" due-to="rewerma">
Add @Column annotation to hint the field name instead of dissecting the get method name.
diff --git a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
index 48afabb..c00fbe8 100644
--- a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
+++ b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
@@ -407,18 +407,15 @@ public abstract class AbstractQueryRunner {
final String... propertyNames) throws SQLException {
PropertyDescriptor[] descriptors;
try {
- descriptors = Introspector.getBeanInfo(bean.getClass())
- .getPropertyDescriptors();
+ descriptors = Introspector.getBeanInfo(bean.getClass()).getPropertyDescriptors();
} catch (final IntrospectionException e) {
- throw new RuntimeException("Couldn't introspect bean "
- + bean.getClass().toString(), e);
+ throw new RuntimeException("Couldn't introspect bean " + bean.getClass().toString(), e);
}
final PropertyDescriptor[] sorted = new PropertyDescriptor[propertyNames.length];
for (int i = 0; i < propertyNames.length; i++) {
final String propertyName = propertyNames[i];
if (propertyName == null) {
- throw new NullPointerException("propertyName can't be null: "
- + i);
+ throw new NullPointerException("propertyName can't be null: " + i);
}
boolean found = false;
for (final PropertyDescriptor descriptor : descriptors) {
@@ -429,8 +426,7 @@ public abstract class AbstractQueryRunner {
}
}
if (!found) {
- throw new RuntimeException("Couldn't find bean property: "
- + bean.getClass() + " " + propertyName);
+ throw new IllegalStateException("Couldn't find bean property: " + bean.getClass() + " " + propertyName);
}
}
fillStatementWithBean(stmt, bean, sorted);