calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vladimirsitni...@apache.org
Subject incubator-calcite git commit: CALCITE-352. Throw exception if ResultSet#next() is called after close()
Date Sat, 29 Nov 2014 13:46:54 GMT
Repository: incubator-calcite
Updated Branches:
  refs/heads/master de0bfaade -> 59657ec75


CALCITE-352. Throw exception if ResultSet#next() is called after close()


Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/59657ec7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/59657ec7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/59657ec7

Branch: refs/heads/master
Commit: 59657ec75981fb1416d127c413a8dd7ae3571a1d
Parents: de0bfaa
Author: Siva Narayanan <snarayanan@qubole.com>
Authored: Sat Nov 29 16:42:07 2014 +0300
Committer: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
Committed: Sat Nov 29 16:43:57 2014 +0300

----------------------------------------------------------------------
 .../main/java/org/apache/calcite/avatica/AvaticaResultSet.java | 3 +++
 core/src/test/java/org/apache/calcite/test/JdbcTest.java       | 6 ++++++
 2 files changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/59657ec7/avatica/src/main/java/org/apache/calcite/avatica/AvaticaResultSet.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/AvaticaResultSet.java b/avatica/src/main/java/org/apache/calcite/avatica/AvaticaResultSet.java
index 4a2e06e..9fdb9f1 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/AvaticaResultSet.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/AvaticaResultSet.java
@@ -198,6 +198,9 @@ public class AvaticaResultSet implements ResultSet, ArrayImpl.Factory
{
 
   public boolean next() throws SQLException {
     // TODO: for timeout, see IteratorResultSet.next
+    if (isClosed()) {
+      throw new SQLException("next() called on closed cursor");
+    }
     if (cursor.next()) {
       ++row;
       return true;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/59657ec7/core/src/test/java/org/apache/calcite/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index 424bbe0..77938d6 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -673,6 +673,12 @@ public class JdbcTest {
     assertEquals(0, closeCount[0]);
     assertEquals(0, statementCloseCount[0]);
     resultSet.close();
+    try {
+      resultSet.next();
+      fail("resultSet.next() should throw SQLException when closed");
+    } catch (SQLException e) {
+      assertThat(e.getMessage(), containsString("next() called on closed cursor"));
+    }
     assertEquals(0, closeCount[0]);
     assertEquals(0, statementCloseCount[0]);
 


Mime
View raw message