Skip to content

Commit b77a5cc

Browse files
committed
ResultSetIterator.get(String) now throws IllegalArgumentException
instead of RuntimeException to wrap cases of SQLException - ResultSetIterator.hasNext() now throws IllegalStateException instead of RuntimeException to wrap cases of SQLException- ResultSetIterator.next() now throws IllegalStateException 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
1 parent 3e82d19 commit b77a5cc

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/changes/changes.xml

+7
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@
4646
<action type="fix" dev="ggregory" due-to="Gary Gregory">The class LocaleBeanUtils no longer extends BeanUtils (both classes only contains static methods).</action>
4747
<action type="fix" dev="ggregory" due-to="Gary Gregory">The class org.apache.commons.beanutils2.BeanUtils is now final (the class only contains static methods).</action>
4848
<action type="fix" dev="ggregory" due-to="Gary Gregory">The constructor org.apache.commons.beanutils2.BeanUtils is now private (the class only contains static methods).</action>
49+
<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>
50+
<action type="fix" dev="ggregory" due-to="Gary Gregory">MappedMethodReference.get() now throws IllegalStateException instead of RuntimeException to wrap cases of NoSuchMethodException.</action>
51+
<action type="fix" dev="ggregory" due-to="Gary Gregory">ResultSetIterator.get(String) now throws IllegalArgumentException instead of RuntimeException to wrap cases of SQLException.</action>
52+
<action type="fix" dev="ggregory" due-to="Gary Gregory">ResultSetIterator.hasNext() now throws IllegalStateException instead of RuntimeException to wrap cases of SQLException.</action>
53+
<action type="fix" dev="ggregory" due-to="Gary Gregory">ResultSetIterator.next() now throws IllegalStateException instead of RuntimeException to wrap cases of SQLException.</action>
54+
<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>
55+
<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>
4956
<!-- ADD -->
5057
<!-- UPDATE -->
5158
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.apache.commons:commons-parent from 78 to 81.</action>

src/main/java/org/apache/commons/beanutils2/BeanComparator.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.commons.beanutils2;
1919

20-
import java.lang.reflect.InvocationTargetException;
2120
import java.util.Comparator;
2221

2322
/**
@@ -157,8 +156,8 @@ public int compare(final T o1, final T o2) {
157156
final Object value1 = PropertyUtils.getProperty(o1, property);
158157
final Object value2 = PropertyUtils.getProperty(o2, property);
159158
return internalCompare(value1, value2);
160-
} catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
161-
throw new RuntimeException(e.getClass().getSimpleName() + ": " + e.toString());
159+
} catch (final ReflectiveOperationException e) {
160+
throw new IllegalArgumentException(e);
162161
}
163162
}
164163

src/main/java/org/apache/commons/beanutils2/MappedPropertyDescriptor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private Method get() {
112112
// Un-comment following line for testing
113113
// System.out.println("Recreated Method " + methodName + " for " + className);
114114
} catch (final NoSuchMethodException e) {
115-
throw new RuntimeException("Method " + methodName + " for " + className + " could not be reconstructed - method not found");
115+
throw new IllegalStateException("Method " + methodName + " for " + className + " could not be reconstructed - method not found");
116116
}
117117
methodRef = new SoftReference<>(m);
118118
}

src/main/java/org/apache/commons/beanutils2/sql/ResultSetIterator.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public Object get(final String name) {
113113
try {
114114
return dynaClass.getObjectFromResultSet(name);
115115
} catch (final SQLException e) {
116-
throw new RuntimeException("get(" + name + "): SQLException: " + e);
116+
throw new IllegalArgumentException("get(" + name + "): SQLException: " + e);
117117
}
118118
}
119119

@@ -170,7 +170,7 @@ public boolean hasNext() {
170170
advance();
171171
return !eof;
172172
} catch (final SQLException e) {
173-
throw new RuntimeException("hasNext(): SQLException: " + e);
173+
throw new IllegalStateException("hasNext(): SQLException: " + e);
174174
}
175175
}
176176

@@ -191,7 +191,7 @@ public DynaBean next() {
191191
current = false;
192192
return this;
193193
} catch (final SQLException e) {
194-
throw new RuntimeException("next(): SQLException: " + e);
194+
throw new IllegalStateException("next(): SQLException: " + e);
195195
}
196196
}
197197

@@ -251,7 +251,7 @@ public void set(final String name, final Object value) {
251251
try {
252252
dynaClass.getResultSet().updateObject(name, value);
253253
} catch (final SQLException e) {
254-
throw new RuntimeException("set(" + name + "): SQLException: " + e);
254+
throw new IllegalArgumentException("set(" + name + "): SQLException: " + e);
255255
}
256256
}
257257

0 commit comments

Comments
 (0)