Xinyi Yan created PHOENIX-6634:
----------------------------------

             Summary: PhoenixResultSet.next method closes the result set if the 
scanner returns null
                 Key: PHOENIX-6634
                 URL: https://issues.apache.org/jira/browse/PHOENIX-6634
             Project: Phoenix
          Issue Type: Bug
    Affects Versions: 4.16.1
            Reporter: Xinyi Yan
             Fix For: 4.17.0, 4.16.2


 
{code:java}
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
    }
} {code}
 

 
{code:java}
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){code}
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



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to