[ https://issues.apache.org/jira/browse/CALCITE-1193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15234523#comment-15234523 ]
Francis Chuang edited comment on CALCITE-1193 at 4/11/16 6:00 AM: ------------------------------------------------------------------ [~elserj]. Here's a simple test case I came up with (hopefully it's valid Java!). Let me know if it's able to reproduce the problem: {code} @Test public void testPreparedStatementWithoutParameters() throws Exception { ConnectionSpec.getDatabaseLock().lock(); try (Connection conn = getLocalConnection(); Statement stmt = conn.createStatement()) { assertTrue(stmt.execute("DROP TABLE IF EXISTS test")); final String sql = "CREATE TABLE test(id integer)"; assertTrue(stmt.execute(sql)); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM test"); assertTrue(pstmt.execute()); } finally { ConnectionSpec.getDatabaseLock().unlock(); } } {code} To run, I used: mvn -DfailIfNoTests=false -Dtest=RemoteDriverTest#testPreparedStatementWithoutParameters -Dcheckstyle.skip=true -e test was (Author: francischuang): [~elserj]. Here's a simple test case I came up with (hopefully it's valid Java!). Let me know if it's able to reproduce the problem: {code} @Test public void testPreparedStatementWithoutParameters() throws Exception { ConnectionSpec.getDatabaseLock().lock(); try (Connection conn = getLocalConnection(); Statement stmt = conn.createStatement()) { assertTrue(stmt.execute("DROP TABLE IF EXISTS test")); final String sql = "CREATE TABLE test(id integer)"; assertTrue(stmt.execute(sql)); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM test"); assertTrue(pstmt.execute()); } finally { ConnectionSpec.getDatabaseLock().unlock(); } } {code} I run, I used: mvn -DfailIfNoTests=false -Dtest=RemoteDriverTest#testPreparedStatementWithoutParameters -Dcheckstyle.skip=true -e test > NullPointerException when trying to execute prepared statement using avatica > ---------------------------------------------------------------------------- > > Key: CALCITE-1193 > URL: https://issues.apache.org/jira/browse/CALCITE-1193 > Project: Calcite > Issue Type: Bug > Components: avatica > Affects Versions: avatica-1.7.1 > Environment: Phoenix 4.7.0 and Phoenix 4.8.0-SNAPSHOT > Reporter: Francis Chuang > Assignee: Josh Elser > > To reproduce, set the phoenix query server to use JSON for serialization: > 1. Create a table called {{my_table}} and seed it using SquirrelSQL: > {code} > CREATE TABLE my_table (k BIGINT PRIMARY KEY, v VARCHAR) TRANSACTIONAL=true > UPSERT INTO my_table VALUES (1,'A') > UPSERT INTO my_table VALUES (2,'B') > UPSERT INTO my_table VALUES (3,'C') > UPSERT INTO my_table VALUES (4,'D') > {code} > Send the following requests using curl: > {code} > C:\Users\user > λ curl localhost:8765 -XPOST --data '{"request": > "openConnection","connectionId": "my-conn"}' > {"response":"openConnection","rpcMetadata":{"response":"rpcMetadata","serverAddress":"f826338-phoenix-server.f826338:8765"}} > C:\Users\user > λ curl localhost:8765 -XPOST --data '{"request": "prepare","connectionId": > "my-conn","sql": "SELECT * FROM my_table","maxRowCount": 1}' > {"response":"prepare","statement":{"connectionId":"my-conn","id":36,"signature":{"columns":[{"ordinal":0,"autoIncrement":false,"caseSensitive":false,"searchable":true,"currency":false,"nullable":0,"signed":true,"displaySize":40,"label":"K","columnName":"K","schemaName":"","precision":0,"scale":0,"tableName":"MY_TABLE","catalogName":"","type":{"type":"scalar","id":-5,"name":"BIGINT","rep":"PRIMITIVE_LONG"},"readOnly":true,"writable":false,"definitelyWritable":false,"columnClassName":"java.lang.Long"},{"ordinal":1,"autoIncrement":false,"caseSensitive":false,"searchable":true,"currency":false,"nullable":1,"signed":false,"displaySize":40,"label":"V","columnName":"V","schemaName":"","precision":0,"scale":0,"tableName":"MY_TABLE","catalogName":"","type":{"type":"scalar","id":12,"name":"VARCHAR","rep":"STRING"},"readOnly":true,"writable":false,"definitelyWritable":false,"columnClassName":"java.lang.String"}],"sql":"SELECT > * FROM > my_table","parameters":[],"cursorFactory":{"style":"LIST","clazz":null,"fieldNames":null},"statementType":null}},"rpcMetadata":{"response":"rpcMetadata","serverAddress":"f826338-phoenix-server.f826338:8765"}} > C:\Users\user > λ curl localhost:8765 -XPOST --data '{"request": "execute","statementHandle": > {"connectionId": "my-conn","id": 36},"maxRowCount": 1}' > {"response":"error","exceptions":["java.lang.NullPointerException\n\tat > org.apache.calcite.avatica.MetaImpl.checkParameterValueHasNull(MetaImpl.java:952)\n\tat > org.apache.calcite.avatica.jdbc.JdbcMeta.execute(JdbcMeta.java:781)\n\tat > org.apache.calcite.avatica.remote.LocalService.apply(LocalService.java:233)\n\tat > > org.apache.calcite.avatica.remote.Service$ExecuteRequest.accept(Service.java:950)\n\tat > > org.apache.calcite.avatica.remote.Service$ExecuteRequest.accept(Service.java:928)\n\tat > > org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:102)\n\tat > > org.apache.calcite.avatica.remote.JsonHandler.apply(JsonHandler.java:43)\n\tat > > org.apache.calcite.avatica.server.AvaticaJsonHandler.handle(AvaticaJsonHandler.java:73)\n\tat > > org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)\n\tat > > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat > org.eclipse.jetty.server.Server.handle(Server.java:497)\n\tat > org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)\n\tat > org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:245)\n\tat > > org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)\n\tat > > org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)\n\tat > > org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)\n\tat > > java.lang.Thread.run(Thread.java:745)\n"],"errorMessage":"NullPointerException: > (null exception > message)","errorCode":-1,"sqlState":"00000","severity":"UNKNOWN","rpcMetadata":{"response":"rpcMetadata","serverAddress":"f826338-phoenix-server.f826338:8765"}} > {code} > Notice that the server throws a NPE when trying to execute the prepared > statement. -- This message was sent by Atlassian JIRA (v6.3.4#6332)