Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayStoreException when invoking a CallableStatement #107

Closed
tydavis76 opened this issue Jul 10, 2014 · 6 comments
Closed

ArrayStoreException when invoking a CallableStatement #107

tydavis76 opened this issue Jul 10, 2014 · 6 comments
Labels

Comments

@tydavis76
Copy link

Encountered a case where a CallableStatement - specifically an instance of CallableStatementJavassistProxy - is being added to a FastList.openStatements lists whose component type is PreparedStatementJavassistProxy. This occurs during a Batch update of hundreds of inserts using PreparedStatements and a single stored-proc call.

@brettwooldridge
Copy link
Owner

Can you provide a stack trace? What version of HikariCP are you using? Currently ConnectionProxy declares the openStatements collection as FastList<Statement>. Both PreparedStatementProxy and CallableStatementProxy are implementers of Statement. And the generated PreparedStatementJavassistProxy extends PreparedStatementProxy and implements the same interfaces (same for CallableStatementJavassistProxy) -- so I'm not sure how an array store exception can occur.

@tydavis76
Copy link
Author

Sure. I will try to gather more information..

On Jul 10, 2014, at 5:55 PM, Brett Wooldridge notifications@github.com wrote:

Can you provide a stack trace? What version of HikariCP are you using? Currently ConnectionProxy declares the openStatements collection as FastList. Both PreparedStatementProxy and CallableStatementProxy are implementers of Statement. And the generated PreparedStatementJavassistProxy extends PreparedStatementProxy and implements the same interfaces (same for CallableStatementJavassistProxy) -- so I'm not sure how an array store exception can occur.


Reply to this email directly or view it on GitHub.

@tydavis76
Copy link
Author

I was able to recreate the problem using version 1.4. Here the test I put together (using spring's JdbcTemplate for convenience):

   @Test
  public void test()
  {
    JdbcTemplate template = new JdbcTemplate(_dataSource);
    template.execute(new ConnectionCallback<Object>()
    {
      @Override
      public Object doInConnection(Connection con) throws SQLException, DataAccessException
      {
        for (int i = 0; i < 100; i++)
        {
          con.prepareStatement("select " + i + " from dual").executeQuery();
        }

        CallableStatement stmt = con.prepareCall("{call DBMS_APPLICATION_INFO.set_client_info(?)}");
        stmt.setString(1, "client info");
        stmt.execute();

        return null;
      }
    });

Note that in order to recreate the problem, I had to issue enough queries to ensure that a few statements were cached BEFORE executing the call to the callable statement.

@brettwooldridge
Copy link
Owner

I have reproduced this issue and will be committing a fix shortly.

@brettwooldridge
Copy link
Owner

@tydavis76 you will need to build the latest development branch to get this fix. The error occurs when there are more than 32 unclosed Statements on a single connection and the statements are of mixed types. When adding the 33rd Statement to the collection we fail to create a new type-compatible backing-array.

git clone https://github.com/brettwooldridge/HikariCP.git
cd HikariCP
cd hikaricp-java6
mvn install

You can then use artifact HikariCP-java6 version 2.0.0-SNAPSHOT as a maven dependency, or copy the HikariCP-java6-2.0.0-SNAPSHOT.jar from the target directory.

@tydavis76
Copy link
Author

thanks for the speedy fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants