diff --git a/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java b/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java index 5f776ff4f..134ac2d35 100644 --- a/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java +++ b/src/main/java/org/apache/commons/dbutils/ResultSetIterator.java @@ -95,11 +95,15 @@ public boolean hasNext() { * columns in the {@code ResultSet}. * @see java.util.Iterator#next() * @throws RuntimeException if an SQLException occurs. + * @throws NoSuchElementException if there are no more rows in the {@code ResultSet}. */ @Override public Object[] next() { try { - return resultSet.next() ? this.convert.toArray(resultSet) : new Object[0]; + if (!resultSet.next()) { + throw new NoSuchElementException("No more rows in the ResultSet"); + } + return this.convert.toArray(resultSet); } catch (final SQLException e) { rethrow(e); return null;