The Outdated Issue of the finalize method for PooldDataSource in Mybatis

47 views
Skip to first unread message

zongle luo

unread,
Dec 9, 2024, 8:58:19 AM12/9/24
to mybatis-user
Hi, I am learning mybatis, and I found that PooledDataSource overrides the finalize method, which may be used to close the database connection when the SqlSessionFactory loses its reference. However, I found that finalize has been marked as obsolete in jdk 9 and may be deleted in future versions, so I wonder if finalize needs to be updated to be processed by cleaner.

If possible, I would like to contribute a PR.

Reference link:

Iwao AVE!

unread,
Dec 27, 2024, 2:16:36 PM12/27/24
to mybati...@googlegroups.com
Hello,

It sounds reasonable.
If it's a small change, please send us a pull request and we will review.
If it's a big change, it may be better to explain your plan first.

Regards,
Iwao

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mybatis-user/afcb99c6-e290-46ab-8276-7028fbe4a421n%40googlegroups.com.

zongle luo

unread,
Dec 28, 2024, 10:16:32 AM12/28/24
to mybatis-user
Oh, sorry, it seems I didn’t check the situation carefully enough. This doesn’t seem to work. 🤣🤣

I was planning to use java.lang.ref.Cleaner to replace finalize because I initially thought MyBatis minimum supported version was Java 17. This was due to encountering errors when running MyBatis with Java 8.

However, today I discovered that MyBatis actually supports running on Java 8. Since java.lang.ref.Cleaner was introduced in Java 9, it seems I can’t use it as a replacement after all. 😂😂

Iwao AVE!

unread,
Dec 28, 2024, 10:52:22 AM12/28/24
to mybati...@googlegroups.com
Thank you for the reply!
We plan to drop Java 8 support in the next minor version 3.6.x, so it is OK to submit a PR when it's ready.

Regards,
Iwao




zongle luo

unread,
Dec 28, 2024, 10:40:31 PM12/28/24
to mybatis-user
OK, thank you very much for your reply
Reply all
Reply to author
Forward
0 new messages