Skip to content

Commit

Permalink
[#7097] Avoid consuming result sets that aren't being closed or scrol…
Browse files Browse the repository at this point in the history
…lable
  • Loading branch information
lukaseder committed Jan 25, 2018
1 parent c8812d0 commit 8f96a58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions jOOQ/src/main/java/org/jooq/impl/DefaultDiagnosticsContext.java
Expand Up @@ -51,6 +51,7 @@
final class DefaultDiagnosticsContext implements DiagnosticsContext {

ResultSet resultSet;
boolean resultSetClosing;
int resultSetFetchedColumns;
int resultSetActualColumns;
int resultSetFetchedRows;
Expand Down Expand Up @@ -90,12 +91,15 @@ public final int resultSetActualRows() {
return -1;

try {
while (resultSet.next())
resultSetActualRows++;
if (resultSetClosing || resultSet.getType() != ResultSet.TYPE_FORWARD_ONLY) {
while (resultSet.next())
resultSetActualRows++;

resultSet.absolute(resultSetFetchedRows);
resultSet.absolute(resultSetFetchedRows);
}
}
catch (SQLException ignore) {}

return resultSetActualRows;
}

Expand Down
1 change: 1 addition & 0 deletions jOOQ/src/main/java/org/jooq/impl/DiagnosticsResultSet.java
Expand Up @@ -745,6 +745,7 @@ public final void close() throws SQLException {
super.absolute(current = rows);

DefaultDiagnosticsContext ctx = ctx();
ctx.resultSetClosing = true;

if (super.next())
connection.listeners.tooManyRowsFetched(ctx);
Expand Down

0 comments on commit 8f96a58

Please sign in to comment.