Skip to content

Commit 913154d

Browse files
authored
Merge pull request #2874 from harawata/undo-invalid-code-optimization
Undo invalid code optimization
2 parents a10d91d + ba7fe1a commit 913154d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,18 @@ private ResultSetWrapper getFirstResultSet(Statement stmt) throws SQLException {
259259
private ResultSetWrapper getNextResultSet(Statement stmt) {
260260
// Making this method tolerant of bad JDBC drivers
261261
try {
262-
// Crazy Standard JDBC way of determining if there are more results
263-
if (stmt.getConnection().getMetaData().supportsMultipleResultSets()
264-
&& (stmt.getMoreResults() || (stmt.getUpdateCount() != -1))) {
265-
ResultSet rs = stmt.getResultSet();
266-
if (rs == null) {
267-
return getNextResultSet(stmt);
262+
if (stmt.getConnection().getMetaData().supportsMultipleResultSets()) {
263+
// Crazy Standard JDBC way of determining if there are more results
264+
// DO NOT try to 'imporove' the condition even if IDE tells you to!
265+
// It's important that getUpdateCount() is called here.
266+
if (!(!stmt.getMoreResults() && stmt.getUpdateCount() == -1)) {
267+
ResultSet rs = stmt.getResultSet();
268+
if (rs == null) {
269+
return getNextResultSet(stmt);
270+
} else {
271+
return new ResultSetWrapper(rs, configuration);
272+
}
268273
}
269-
return new ResultSetWrapper(rs, configuration);
270274
}
271275
} catch (Exception e) {
272276
// Intentionally ignored.

src/main/java/org/apache/ibatis/jdbc/ScriptRunner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ private void executeStatement(String command) throws SQLException {
248248
}
249249
try {
250250
boolean hasResults = statement.execute(sql);
251-
while ((hasResults || (statement.getUpdateCount() != -1))) {
251+
// DO NOT try to 'imporove' the condition even if IDE tells you to!
252+
// It's important that getUpdateCount() is called here.
253+
while (!(!hasResults && statement.getUpdateCount() == -1)) {
252254
checkWarnings(statement);
253255
printResults(statement, hasResults);
254256
hasResults = statement.getMoreResults();

0 commit comments

Comments
 (0)