Skip to content

MBeanExporter/MBeanRegistrationSupport lack synchronization [SPR-11002] #15630

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 Oct 18, 2013 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Piotr Findeisen opened SPR-11002 and commented

MBeanExporter, MBeanRegistrationSupport lack any for of synchronization and there are many things that can happen if they are used from 2+ threads.

##### steps
1. `REGISTRATION_REPLACE_EXISTING` is `true`
1. thread 1: register called with name `nameA`
1. thread 1: registration completes
1. thread 2: register called with name `nameA`
1. thread 2: gets `InstanceAlreadyExistsException`
1. thread 1: unregisters `nameA`
1. thread 2: handles `InstanceAlreadyExistsException` by calling `this.server.unregisterMBean(objectName);`

##### expected
 * `registrationBehavior == REGISTRATION_REPLACE_EXISTING` should prevent any `InstanceAlreadyExistsException` from being propagated to the callers

##### observed
 * indeed, `InstanceAlreadyExistsException` is not propagated
 * but `InstanceNotFoundException` is raised instead
##### steps
1. thread 1: calls register `nameA`
1. thread 1: registration completes
1. thread 1: calls unregister `nameA`
1. thread 1: `nameA` is removed from the server but not yet from `registeredBeans`
1. thread 2: calls register `nameA`
1. thread 2: registration completes; `nameA` is not added to `registeredBeans` because it is already there
1. thread 1: unregistration completes, `nameA` is removed from `registeredBeans`

##### expected
 * `registeredBeans` should be a `Set` of all registered MBeans

##### observed
 * `nameA` is registered but is not present in `registeredBeans`
 * later call to `MBeanExporter.destroy()` (like application redeployment) will leave `nameA` registered in the server

Affects: 3.1.2, 3.1.4

Referenced from: commits 1ea218c, 8d6d6be

Backported to: 3.2.6

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Oct 18, 2013

Piotr Findeisen commented

I noticed that #14086 & Juergen Hoeller's 3dd8175 wraps registeredBeans into Collections.synchronizedSet. This is a good change, but certainly insufficient.

@spring-projects-issues spring-projects-issues added type: bug A general bug 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 4.0 GA 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) 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