You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Gregory Hart (Jira)" <ji...@apache.org> on 2022/04/27 17:58:00 UTC
[jira] [Created] (CALCITE-5121) Rethrow RuntimeException as SQLException in Driver#onConnectionInit
Gregory Hart created CALCITE-5121:
-------------------------------------
Summary: Rethrow RuntimeException as SQLException in Driver#onConnectionInit
Key: CALCITE-5121
URL: https://issues.apache.org/jira/browse/CALCITE-5121
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.30.0
Reporter: Gregory Hart
The documentation for org.apache.calcite.avatica.Handler#onConnectionInit states that a SQLException should be thrown "on error". However, the implementation of onConnectInit in org.apache.calcite.jdbc.Driver allows for other types of exceptions to be thrown. This also breaks the documentation contract for java.sql.Driver#connect since a RuntimeException could be throw instead of the expected SQLException.
*Steps to reproduce:*
DriverManager.getConnection("jdbc:calcite:schemaType=JDBC;schema.jdbcUrl=jdbc:invalid:");
*Expected result:*
A SQLException is thrown
*Actual result:*
A RuntimeException is thrown
{code:java}
java.lang.RuntimeException: Error instantiating JsonCustomSchema(name=adhoc)
at org.apache.calcite.model.ModelHandler.visit(ModelHandler.java:277)
at org.apache.calcite.model.JsonCustomSchema.accept(JsonCustomSchema.java:66)
at org.apache.calcite.model.ModelHandler.visit(ModelHandler.java:200)
at org.apache.calcite.model.ModelHandler.<init>(ModelHandler.java:106)
at org.apache.calcite.jdbc.Driver$1.onConnectionInit(Driver.java:101)
at org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:139)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270){code}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)