Rymar Maksym created CALCITE-4814:
-------------------------------------

             Summary: AvaticaConnection#isValid() doesn't correspond JDBC API
                 Key: CALCITE-4814
                 URL: https://issues.apache.org/jira/browse/CALCITE-4814
             Project: Calcite
          Issue Type: Bug
          Components: avatica
            Reporter: Rymar Maksym


[AvaticaConnection|https://github.com/apache/calcite-avatica/blob/d52c2036224911d93fe3185f521768037e62a437/core/src/main/java/org/apache/calcite/avatica/AvaticaConnection.java#L63]
 implements Connection interface of JDBC APi, but it's isValid() method doesn't 
correspond [java documentation|#isValid(int)].]

Currently, {{AvaticaConnection}} only checks attribute {{'closed'}} via method 
{{isClosed()}} and do nothing more. With current implementation, 
{{AvaticaConnection#isValid(int timeout)}} totally correspond to 
{{AvaticaConnection#isClosed()}} what is actually incorrect, according to [java 
documentation|#isValid(int)]].

In it's turn, {{AvaticaConnection#isClosed()}} will return {{'true'}}, only 
when connection will be closed directly by client and it doesn't handle case, 
when server closes connection or server is not accessible due to network issues 
and etc.

{{AvaticaConnection#isValid}} should check weather connection is valid. The 
driver may submit a query on the connection or use some other mechanism that 
positively verifies the connection is still valid when this method is called.

Here is some examples of implementations in [MySql 
JDBC|https://github.com/mysql/mysql-connector-j/blob/18bbd5e68195d0da083cbd5bd0d05d76320df7cd/src/main/user-impl/java/com/mysql/cj/jdbc/ConnectionImpl.java#L2546]
 and [Postgres 
JDBC|https://github.com/pgjdbc/pgjdbc/blob/3a2bbd77969903f8a4ce721d45905c72bd1688d6/pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java#L1407].

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to