Skip to content

Commit 5469692

Browse files
committed
ResultSetIterator.get(String) now throws IllegalArgumentException
instead of RuntimeException to wrap cases of SQLException - ResultSetIterator.hasNext() now throws IllegalArgumentException instead of RuntimeException to wrap cases of SQLException - ResultSetIterator.set(String, Object) now throws IllegalArgumentException instead of RuntimeException to wrap cases of SQLException - ResultSetIterator.set(String, String, Object) now throws IllegalArgumentException instead of RuntimeException to wrap cases of SQLException.</action>
1 parent b1f5abc commit 5469692

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/changes/changes.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
<!-- FIX -->
3333
<action type="fix" dev="ggregory" due-to="Gary Gregory">BeanComparator.compare(T, T) now throws IllegalArgumentException instead of RuntimeException to wrap all cases of ReflectiveOperationException.</action>
3434
<action type="fix" dev="ggregory" due-to="Gary Gregory">MappedMethodReference.get() now throws IllegalStateException instead of RuntimeException to wrap cases of NoSuchMethodException.</action>
35+
<action type="fix" dev="ggregory" due-to="Gary Gregory">ResultSetIterator.get(String) now throws IllegalArgumentException instead of RuntimeException to wrap cases of SQLException.</action>
36+
<action type="fix" dev="ggregory" due-to="Gary Gregory">ResultSetIterator.hasNext() now throws IllegalArgumentException instead of RuntimeException to wrap cases of SQLException.</action>
37+
<action type="fix" dev="ggregory" due-to="Gary Gregory">ResultSetIterator.set(String, Object) now throws IllegalArgumentException instead of RuntimeException to wrap cases of SQLException.</action>
38+
<action type="fix" dev="ggregory" due-to="Gary Gregory">ResultSetIterator.set(String, String, Object) now throws IllegalArgumentException instead of RuntimeException to wrap cases of SQLException.</action>
3539
<!-- ADD -->
3640
<!-- UPDATE -->
3741
</release>

src/main/java/org/apache/commons/beanutils/ResultSetIterator.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ public Object get(final String name) {
110110
try {
111111
return dynaClass.getObjectFromResultSet(name);
112112
} catch (final SQLException e) {
113-
throw new RuntimeException
114-
("get(" + name + "): SQLException: " + e);
113+
throw new IllegalArgumentException("get(" + name + "): SQLException: " + e, e);
115114
}
116115
}
117116

@@ -177,7 +176,7 @@ public boolean hasNext() {
177176
advance();
178177
return !eof;
179178
} catch (final SQLException e) {
180-
throw new RuntimeException("hasNext(): SQLException: " + e);
179+
throw new IllegalArgumentException("hasNext(): SQLException: " + e, e);
181180
}
182181
}
183182

@@ -196,7 +195,7 @@ public DynaBean next() {
196195
current = false;
197196
return this;
198197
} catch (final SQLException e) {
199-
throw new RuntimeException("next(): SQLException: " + e);
198+
throw new IllegalArgumentException("next(): SQLException: " + e, e);
200199
}
201200

202201
}
@@ -267,8 +266,7 @@ public void set(final String name, final Object value) {
267266
try {
268267
dynaClass.getResultSet().updateObject(name, value);
269268
} catch (final SQLException e) {
270-
throw new RuntimeException
271-
("set(" + name + "): SQLException: " + e);
269+
throw new IllegalArgumentException("set(" + name + "): SQLException: " + e, e);
272270
}
273271
}
274272

@@ -287,8 +285,7 @@ public void set(final String name, final Object value) {
287285
*/
288286
@Override
289287
public void set(final String name, final String key, final Object value) {
290-
throw new UnsupportedOperationException
291-
("FIXME - mapped properties not currently supported");
288+
throw new UnsupportedOperationException("FIXME - mapped properties not currently supported");
292289
}
293290

294291
}

0 commit comments

Comments
 (0)