Inconsistent synchronization in AbstractBeanFactoryBasedTargetSource and JdbcAccessor [SPR-16570] #21112
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Juergen Hoeller opened SPR-16570 and commented
As pointed out by #1725,
AbstractBeanFactoryBasedTargetSource.getTargetClass()
andJdbcAccessor.getExceptionTranslator()
are marked assynchronized
but their corresponding setter methods aren't... which may lead to inconsistent visibility at runtime.Since all we want to prevent there is entering the lazy initialization algorithm concurrently, we can use a
volatile
field instead, only entering full synchronization when no existing instance has been found. Once initialized, we're happy to go with whatever has been set, so a volatile field is sufficient there.Affects: 4.3.14, 5.0.4
Referenced from: commits a403a75, 7f1a8d7, 207e8c2, 1bde920, 50253f6
Backported to: 4.3.15
The text was updated successfully, but these errors were encountered: