Skip to content

Inconsistent synchronization in AbstractBeanFactoryBasedTargetSource and JdbcAccessor [SPR-16570] #21112

Closed
@spring-projects-issues

Description

@spring-projects-issues

Juergen Hoeller opened SPR-16570 and commented

As pointed out by #1725, AbstractBeanFactoryBasedTargetSource.getTargetClass() and JdbcAccessor.getExceptionTranslator() are marked as synchronized 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

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions