Bug #109681 NullPointerException in StatementImpl::getWarnings
Submitted: 18 Jan 2023 13:45 Modified: 23 Jun 2023 11:40
Reporter: Jens Teglhus Møller Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.0.33 OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[18 Jan 2023 13:45] Jens Teglhus Møller
Description:
Hi

There seems to be some kind of race condition between closing connections and statements.

I'm able to reliable trigger a NullPointerException in StatementImpl::getWarnings due to session being null (because the connection was closed by another thread).

I initially thought this was a problem related to interactions between the hikaricp connection pool and the jooq framework, but after reporting the bug on the jooq mailing list <https://groups.google.com/g/jooq-user/c/mvrKSt47h4Q> I was directed here.

How to repeat:
There is probably a simple way to trigger this, but I have created a small project on github that reproduces it by using testcontainers, hikaricp and jooq: https://github.com/djarnis73/jooq-hikari

If that is too much clutter, I can see if I can reproduce it without involving third party libraries.
[20 Apr 2023 14:24] Jens Teglhus Møller
I have updated the repository for the just released 8.0.33 and the bug is still here. I also changed the maven surefire configuration so it displays the full stack trace.

The NPE part is:
Caused by: java.lang.NullPointerException
	at com.mysql.cj.jdbc.StatementImpl.getWarnings(StatementImpl.java:1733)
	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.getWarnings(HikariProxyPreparedStatement.java)
	at org.jooq.tools.jdbc.DefaultStatement.getWarnings(DefaultStatement.java:211)
	at org.jooq.impl.Tools.consumeWarnings(Tools.java:4278)
	at org.jooq.impl.Tools.safeClose(Tools.java:3143)
	at org.jooq.impl.Tools.safeClose(Tools.java:3130)
	at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:362)
	at jooqbug.JooqHikariMysqlTest.lambda$timeoutTestTransaction$1(JooqHikariMysqlTest.java:58)
[21 Apr 2023 12:49] MySQL Verification Team
Hello,

Thank you for the bug report.
Could you please provide repeatable test case (please make it as private if you prefer) to reproduce this issue at our end? Thank you.

Regards,
Ashwini Patil
[21 Apr 2023 12:55] Jens Teglhus Møller
Does the one I provided on github not work for you (just clone it and run ./mvnw test)?
[23 May 2023 11:40] Filipe Silva
Hi Jens,

Thank you for filing this report and providing a test case. The problem is that we can't debug third party libraries so, although the explanation provided in the jooq mailing list sounds reasonable, we do need a test case that exposes the issue using Connector/J only, which is especially significant in concurrency related issues. It would much appreciated if you could provide such test case.

Thanks,
[24 Jun 2023 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".