[CONJ-716] NPE with ProtocolLoggingProxy Created: 2019-07-08  Updated: 2019-07-09  Resolved: 2019-07-09

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 2.4.2
Fix Version/s: 2.4.3

Type: Bug Priority: Major
Reporter: Bogdan S Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

Got NullPointerException on service start.

Setup:

  • MariaDB J connector v2.4.2
  • HikariCP v3.3.1
  • MySQL v5.6 server
  • openjdk version "11.0.3" 2019-04-16 LTS
    • OpenJDK 64-Bit Server VM Zulu11.31+10-SA (build 11.0.3+7-LTS, mixed mode)

    connectionInitSql = "SET time_zone = '+0:00';"
    # DataSource properties
    properties {
      profileSQL = true
    }

ERROR [2019-07-08T10:36:52.143Z] [MySQL XXX cluster connection adder] [c.zaxxer.hikari.pool.HikariPool] MySQL XXX cluster - Error thrown while acquiring connection from data source
java.lang.NullPointerException: null
        at java.base/java.text.DecimalFormat.resetFastPathData(DecimalFormat.java:1111)
        at java.base/java.text.DecimalFormat.checkAndSetFastPathStatus(DecimalFormat.java:1040)
        at java.base/java.text.DecimalFormat.fastFormat(DecimalFormat.java:1618)
        at java.base/java.text.NumberFormat.format(NumberFormat.java:324)
        at org.mariadb.jdbc.internal.logging.ProtocolLoggingProxy.invoke(ProtocolLoggingProxy.java:116)
        at com.sun.proxy.$Proxy11.executeQuery(Unknown Source)
        at org.mariadb.jdbc.MariaDbStatement.executeInternal(MariaDbStatement.java:332)
        at org.mariadb.jdbc.MariaDbStatement.executeQuery(MariaDbStatement.java:512)
        at org.mariadb.jdbc.MariaDbConnection.getTransactionIsolation(MariaDbConnection.java:931)
        at com.zaxxer.hikari.pool.PoolBase.checkDefaultIsolation(PoolBase.java:471)
        at com.zaxxer.hikari.pool.PoolBase.checkDriverSupport(PoolBase.java:434)
        at com.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:402)
        at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:355)
        at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
        at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
        at com.zaxxer.hikari.pool.HikariPool.access$100(HikariPool.java:71)
        at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:727)
        at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:713)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)



 Comments   
Comment by Bogdan S [ 2019-07-08 ]

Same issue?
https://stackoverflow.com/questions/26514290/why-does-numberformat-format-throw-an-nullpointerexception

According to the documentation of NumberFormat, the class is not thread-safe, so concurrent access must be synchronized externally:

Number formats are generally not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.

https://docs.oracle.com/javase/8/docs/api/java/text/NumberFormat.html


If thats the case, are these MariaDB classes (usage) supposed to be thread-safe? Or the issue is with HikariCP?

Comment by Diego Dupin [ 2019-07-09 ]

It seems you found the issue and the answer.
Since access to this method is protected by ReentrantLock per connection, the problem can only be caused by having NumberFormat defined in a static fashion.
corrected with commit https://github.com/MariaDB/mariadb-connector-j/commit/612c2fe9c3f252deb5322c6b168f72c95f27e3aa

Generated at Thu Feb 08 03:17:47 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.