You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Kevin Risden (Jira)" <ji...@apache.org> on 2021/09/30 14:12:00 UTC

[jira] [Commented] (CALCITE-4814) AvaticaConnection#isValid() doesn't correspond JDBC API

    [ https://issues.apache.org/jira/browse/CALCITE-4814?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17422807#comment-17422807 ] 

Kevin Risden commented on CALCITE-4814:
---------------------------------------

[~mrymar] - agree there is room for improvement in the isValid method. Previously without isValid implemented at all - many clients wouldn't even work at all since they call isValid before doing anything else. Feel free to submit a PR to improve this.

> 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
>            Priority: Major
>
> [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)