mybatis / mybatis-3

MyBatis SQL mapper framework for Java
http://mybatis.github.io/mybatis-3/
Apache License 2.0
19.55k stars 12.74k forks source link

fix: Double-checked locking for logConstructor #3154

Closed qingbozhang closed 1 week ago

qingbozhang commented 2 months ago

When the tryImplementation method is called concurrently, the value of logConstructor may be overwritten. So I'm going to use DCL to solve this problem.

harawata commented 2 months ago

Thank you for the PR, @qingbozhang .

We have just eliminated synchronized blocks ( #3017 ). Besides, enclosing Runnable#run() in synchronized may not achieve anything.

Are you actually experiencing some problem? If so, please provide information for how to reproduce the problem.

qingbozhang commented 2 months ago

Not yet. It just happen in theory. I see ( https://github.com/mybatis/mybatis-3/pull/3017 ).
I can use lock field replace synchronized if necessary, and I can close this PR if not