Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-6634

PhoenixResultSet.next method closes the result set if the scanner returns null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.16.1
    • 4.17.0, 4.16.2
    • None
    • None

    Description

       

      public void test() throws Exception {
          String query = "SELECT a_string FROM " + tableName + " WHERE organization_id=? LIMIT 1";
          Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
      
          try(Connection conn = DriverManager.getConnection(getUrl(), props)) {
              PreparedStatement statement = conn.prepareStatement(query);
              statement.setString(1, tenantId);
              ResultSet rs = statement.executeQuery();
              while (rs.next()) {
      
              }
              assertFalse(rs.next()); // exception happens here
          }
      } 

       

       

      java.sql.SQLException: ERROR 1101 (XCL01): ResultSet is closed.    at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:615)
          at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:217)
          at org.apache.phoenix.jdbc.PhoenixResultSet.checkOpen(PhoenixResultSet.java:288)
          at org.apache.phoenix.jdbc.PhoenixResultSet.next(PhoenixResultSet.java:847)
          at org.apache.phoenix.end2end.QueryIT.test(QueryIT.java:184)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      Need to remove the unnecessary close inside the next method. 

       

      https://github.com/apache/phoenix/blob/4.x/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixResultSet.java#L855

      Attachments

        Issue Links

          Activity

            People

              yanxinyi Xinyi Yan
              yanxinyi Xinyi Yan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: