Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-443

NullpointerException when making concurrent procedure calls

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.5.8
    • 2.0.0-RC, 1.6.0
    • Other
    • None

    Description

      I am making the same call to a store procedure multiple times with very little change in the arguments. The first call succeeds but the second call creates a null pointer exception.

      The problem is caused at line 487 of MariaDbConnection class. That is when the callableStatementCache is adding a new callableStatement. That callableStatement has a the sql field populated but the value for the items that is added to the callableStatementCache has null sql field. When that value is fetched on line 479 the clone fails with a NullPointerException because the sql field cannot be null.

      Below is the stack trace.
      java.lang.NullPointerException
      at org.mariadb.jdbc.MariaDbServerPreparedStatement.prepare(MariaDbServerPreparedStatement.java:143) at org.mariadb.jdbc.MariaDbServerPreparedStatement.clone(MariaDbServerPreparedStatement.java:134) at org.mariadb.jdbc.AbstractCallableProcedureStatement.clone(AbstractCallableProcedureStatement.java:99) at org.mariadb.jdbc.MariaDbProcedureStatement.clone(MariaDbProcedureStatement.java:119) at org.mariadb.jdbc.MariaDbProcedureStatement.clone(MariaDbProcedureStatement.java:62) at org.mariadb.jdbc.MariaDbConnection.prepareCall(MariaDbConnection.java:479) at com.zaxxer.hikari.pool.ProxyConnection.prepareCall(ProxyConnection.java:289) at com.zaxxer.hikari.pool.HikariProxyConnection.prepareCall(HikariProxyConnection.java)

      Attachments

        Activity

          The only NPE that can be thrown here is if `protocol` is null.
          And AFAIK this can only happen if the statement has been closed.

                      serverPrepareResult = protocol.prepare(sql, mustExecuteOnMaster);
          

          beders Jochen Bedersdorfer added a comment - The only NPE that can be thrown here is if `protocol` is null. And AFAIK this can only happen if the statement has been closed. serverPrepareResult = protocol.prepare(sql, mustExecuteOnMaster);

          See screenshot. Breakpoint triggered on protocol == null.
          Not sure how closed statements made it into the pool - or remained there.

          beders Jochen Bedersdorfer added a comment - See screenshot. Breakpoint triggered on protocol == null. Not sure how closed statements made it into the pool - or remained there.

          Work-around: disable callable prep stmt cache. Add this to your JDBC-URL:
          cacheCallableStmts=false

          beders Jochen Bedersdorfer added a comment - Work-around: disable callable prep stmt cache. Add this to your JDBC-URL: cacheCallableStmts=false

          People

            diego dupin Diego Dupin
            JStringer Jonathan Stringer
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.