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

Null Pointer Exception on getConnection()

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 2.2.4, 2.2.5, 2.2.6
    • 2.3.0, 1.8.0
    • Failover
    • None
    • Amazon Linux
      Java 8

    Description

      We are connecting to an AWS Aurora RDS datasource using a connection string that looks like this:
      jdbc:mariadb:aurora://XXXXX.cluster-XXXXX.eu-west-1.rds.amazonaws.com:3306/XXXXX?socketTimeout=0&useSSL=true&connectTimeout=31000

      When calling getConnection(), we see this error message. It looks like there is a NullPointerException occuring somewhere within the driver code:

      java.lang.NullPointerException: null
      	at org.mariadb.jdbc.internal.failover.AbstractMastersListener.throwFailoverMessage(AbstractMastersListener.java:506)
      	at org.mariadb.jdbc.internal.failover.impl.MastersSlavesListener.checkInitialConnection(MastersSlavesListener.java:300)
      	at org.mariadb.jdbc.internal.failover.impl.MastersSlavesListener.initializeConnection(MastersSlavesListener.java:169)
      	at org.mariadb.jdbc.internal.failover.FailoverProxy.<init>(FailoverProxy.java:116)
      	at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:485)
      	at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:155)
      	at org.mariadb.jdbc.MariaDbDataSource.getConnection(MariaDbDataSource.java:288)
      

      We first saw this after upgrading to 2.2.5.

      Attachments

        Activity

          It turns out this wasn't related to the upgrade to 2.2.5, but 2.2.5 has a change that changed it from a meaningful exception to this NullPointerException.

          If we downgrade to 2.2.4, we get a better stack trace.

          java.sql.SQLException: Communications link failure with primary. No active connection found for master. 
          	at org.mariadb.jdbc.internal.failover.AbstractMastersListener.throwFailoverMessage(AbstractMastersListener.java:487)
          	at org.mariadb.jdbc.internal.failover.impl.MastersSlavesListener.checkInitialConnection(MastersSlavesListener.java:176)
          	at org.mariadb.jdbc.internal.failover.impl.MastersSlavesListener.initializeConnection(MastersSlavesListener.java:162)
          	at org.mariadb.jdbc.internal.failover.FailoverProxy.<init>(FailoverProxy.java:101)
          	at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:477)
          	at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:150)
          	at org.mariadb.jdbc.MariaDbDataSource.getConnection(MariaDbDataSource.java:288)
          	...
          

          Despite the fact that the underlying issue is with our connection string and not a problem with the driver, I still think we wouldn't want an incorrect hostname in a connection string to lead to an NPE, so I'll leave this open, but lower the priority.

          joseph.witthuhn Joseph Witthuhn added a comment - It turns out this wasn't related to the upgrade to 2.2.5, but 2.2.5 has a change that changed it from a meaningful exception to this NullPointerException. If we downgrade to 2.2.4, we get a better stack trace. java.sql.SQLException: Communications link failure with primary. No active connection found for master. at org.mariadb.jdbc.internal.failover.AbstractMastersListener.throwFailoverMessage(AbstractMastersListener.java:487) at org.mariadb.jdbc.internal.failover.impl.MastersSlavesListener.checkInitialConnection(MastersSlavesListener.java:176) at org.mariadb.jdbc.internal.failover.impl.MastersSlavesListener.initializeConnection(MastersSlavesListener.java:162) at org.mariadb.jdbc.internal.failover.FailoverProxy.<init>(FailoverProxy.java:101) at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:477) at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:150) at org.mariadb.jdbc.MariaDbDataSource.getConnection(MariaDbDataSource.java:288) ... Despite the fact that the underlying issue is with our connection string and not a problem with the driver, I still think we wouldn't want an incorrect hostname in a connection string to lead to an NPE, so I'll leave this open, but lower the priority.

          We are actually getting a different NullPointerException in 2.2.4, but at a very low frequency (about 1 time in every 200 connection attempts). We rolled back to 2.2.1 (which we have been using since January without issue), and the issue went away.

          java.lang.NullPointerException: null
          	at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at org.mariadb.jdbc.internal.failover.AbstractMastersListener.invoke(AbstractMastersListener.java:381)
          	at org.mariadb.jdbc.internal.failover.FailoverProxy.executeInvocation(FailoverProxy.java:229)
          	at org.mariadb.jdbc.internal.failover.FailoverProxy.invoke(FailoverProxy.java:222)
          	at com.sun.proxy.$Proxy17.versionGreaterOrEqual(Unknown Source)
          	at org.mariadb.jdbc.MariaDbConnection.<init>(MariaDbConnection.java:128)
          	at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:151)
          	at org.mariadb.jdbc.Driver.connect(Driver.java:86)
          

          This might belong as a separate bug report - I can create a separate issue if you'd prefer it to be reported that way.

          joseph.witthuhn Joseph Witthuhn added a comment - We are actually getting a different NullPointerException in 2.2.4, but at a very low frequency (about 1 time in every 200 connection attempts). We rolled back to 2.2.1 (which we have been using since January without issue), and the issue went away. java.lang.NullPointerException: null at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mariadb.jdbc.internal.failover.AbstractMastersListener.invoke(AbstractMastersListener.java:381) at org.mariadb.jdbc.internal.failover.FailoverProxy.executeInvocation(FailoverProxy.java:229) at org.mariadb.jdbc.internal.failover.FailoverProxy.invoke(FailoverProxy.java:222) at com.sun.proxy.$Proxy17.versionGreaterOrEqual(Unknown Source) at org.mariadb.jdbc.MariaDbConnection.<init>(MariaDbConnection.java:128) at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:151) at org.mariadb.jdbc.Driver.connect(Driver.java:86) This might belong as a separate bug report - I can create a separate issue if you'd prefer it to be reported that way.

          We continue to see the same NullPointerException issue from 2.2.5 in 2.2.6.

          Here is an updated stack trace with updated line numbers for 2.2.6:

          java.lang.NullPointerException: null
                         at org.mariadb.jdbc.internal.failover.impl.MastersSlavesListener.versionGreaterOrEqual(MastersSlavesListener.java:223)
                         at org.mariadb.jdbc.internal.failover.FailoverProxy.invoke(FailoverProxy.java:163)
                         at com.sun.proxy.$Proxy18.versionGreaterOrEqual(Unknown Source)
                         at org.mariadb.jdbc.MariaDbConnection.<init>(MariaDbConnection.java:133)
                         at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:156)
                         at org.mariadb.jdbc.Driver.connect(Driver.java:86)
                         at org.flywaydb.core.internal.util.jdbc.DriverDataSource.getConnectionFromDriver(DriverDataSource.java:409)
                         at org.flywaydb.core.internal.util.jdbc.DriverDataSource.getConnection(DriverDataSource.java:370)
                         at org.flywaydb.core.internal.util.jdbc.JdbcUtils.openConnection(JdbcUtils.java:50)
                         at org.flywaydb.core.Flyway.execute(Flyway.java:1327)
          

          (The context here is that the calls are coming via Flyway 4.0.3...)

          joseph.witthuhn Joseph Witthuhn added a comment - We continue to see the same NullPointerException issue from 2.2.5 in 2.2.6. Here is an updated stack trace with updated line numbers for 2.2.6: java.lang.NullPointerException: null at org.mariadb.jdbc.internal.failover.impl.MastersSlavesListener.versionGreaterOrEqual(MastersSlavesListener.java:223) at org.mariadb.jdbc.internal.failover.FailoverProxy.invoke(FailoverProxy.java:163) at com.sun.proxy.$Proxy18.versionGreaterOrEqual(Unknown Source) at org.mariadb.jdbc.MariaDbConnection.<init>(MariaDbConnection.java:133) at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:156) at org.mariadb.jdbc.Driver.connect(Driver.java:86) at org.flywaydb.core.internal.util.jdbc.DriverDataSource.getConnectionFromDriver(DriverDataSource.java:409) at org.flywaydb.core.internal.util.jdbc.DriverDataSource.getConnection(DriverDataSource.java:370) at org.flywaydb.core.internal.util.jdbc.JdbcUtils.openConnection(JdbcUtils.java:50) at org.flywaydb.core.Flyway.execute(Flyway.java:1327) (The context here is that the calls are coming via Flyway 4.0.3...)

          People

            diego dupin Diego Dupin
            joseph.witthuhn Joseph Witthuhn
            Votes:
            0 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.