Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Mar 8, 2018 · 0 comments
Assignees
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

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues spring-projects-issues added type: bug A general bug in: data Issues in data modules (jdbc, orm, oxm, tx) status: backported An issue that has been backported to maintenance branches in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0.5 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants