Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
If you connect to a JDBC data source using a model that has invalid JSON attributes, you can get a NullPointerException. Optiq should give an error, but it should not give a NullPointerException.
Here is the schema:
```json
{
version: '1.0',
defaultSchema: 'steelwheels',
schemas: [
{
name: 'steelwheels',
type: 'custom',
factory: 'net.hydromatic.optiq.impl.jdbc.JdbcSchema$Factory',
operand:
}
]
}
```
and here is the exception:
```
sqlline> !connect jdbc:optiq:model=steelwheels.json admin admin
java.lang.RuntimeException: Error instantiating JsonCustomSchema(name=steelwheels)
at net.hydromatic.optiq.model.ModelHandler.visit(ModelHandler.java:123)
at net.hydromatic.optiq.model.JsonCustomSchema.accept(JsonCustomSchema.java:37)
at net.hydromatic.optiq.model.ModelHandler.visit(ModelHandler.java:71)
at net.hydromatic.optiq.model.ModelHandler.<init>(ModelHandler.java:63)
at net.hydromatic.optiq.jdbc.Driver$1.onConnectionInit(Driver.java:92)
at net.hydromatic.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:123)
at sqlline.DatabaseConnection.connect(DatabaseConnection.java:157)
at sqlline.DatabaseConnection.getConnection(DatabaseConnection.java:203)
at sqlline.Commands.connect(Commands.java:1064)
at sqlline.Commands.connect(Commands.java:996)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:36)
at sqlline.SqlLine.dispatch(SqlLine.java:804)
at sqlline.SqlLine.begin(SqlLine.java:681)
at sqlline.SqlLine.start(SqlLine.java:398)
at sqlline.SqlLine.main(SqlLine.java:292)
Caused by: java.lang.RuntimeException: Error while reading dataSource
at net.hydromatic.optiq.impl.jdbc.JdbcSchema.create(JdbcSchema.java:118)
at net.hydromatic.optiq.impl.jdbc.JdbcSchema$Factory.create(JdbcSchema.java:335)
at net.hydromatic.optiq.model.ModelHandler.visit(ModelHandler.java:117)
... 18 more
Caused by: java.lang.NullPointerException
at net.hydromatic.optiq.impl.jdbc.JdbcSchema.dataSource(JdbcSchema.java:135)
at net.hydromatic.optiq.impl.jdbc.JdbcSchema.create(JdbcSchema.java:115)
... 20 more
```
The driver, url, user and password attributes should have been jdbcDriver, jdbcUrl, jdbcUser, jdbcPassword.
To fix this bug, make sure that a proper error message is raised, and add a test case.
---------------- Imported from GitHub ----------------
Url: https://github.com/julianhyde/optiq/issues/144
Created by: julianhyde
Labels: bug,
Created at: Wed Feb 19 19:07:17 CET 2014
State: open
Attachments
Issue Links
- is fixed by
-
CALCITE-4199 Add nullability annotations to the methods and fields, ensure consistency with checkerframework
- Closed