HHH-13209 Disallow races between destroy and reactivation of ServiceRegistry
This commit is contained in:
parent
cc3e4c82d3
commit
5e30e509b3
|
@ -206,7 +206,7 @@ public class BootstrapServiceRegistryImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
public synchronized void destroy() {
|
||||
if ( !active ) {
|
||||
return;
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ public class BootstrapServiceRegistryImpl
|
|||
}
|
||||
}
|
||||
|
||||
private void destroy(ServiceBinding serviceBinding) {
|
||||
private synchronized void destroy(ServiceBinding serviceBinding) {
|
||||
serviceBinding.getLifecycleOwner().stopService( serviceBinding );
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ public class BootstrapServiceRegistryImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public <R extends Service> void stopService(ServiceBinding<R> binding) {
|
||||
public synchronized <R extends Service> void stopService(ServiceBinding<R> binding) {
|
||||
final Service service = binding.getService();
|
||||
if ( Stoppable.class.isInstance( service ) ) {
|
||||
try {
|
||||
|
@ -272,7 +272,7 @@ public class BootstrapServiceRegistryImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerChild(ServiceRegistryImplementor child) {
|
||||
public synchronized void registerChild(ServiceRegistryImplementor child) {
|
||||
if ( childRegistries == null ) {
|
||||
childRegistries = new HashSet<ServiceRegistryImplementor>();
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ public class BootstrapServiceRegistryImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deRegisterChild(ServiceRegistryImplementor child) {
|
||||
public synchronized void deRegisterChild(ServiceRegistryImplementor child) {
|
||||
if ( childRegistries == null ) {
|
||||
throw new IllegalStateException( "No child ServiceRegistry registrations found" );
|
||||
}
|
||||
|
|
|
@ -382,7 +382,7 @@ public abstract class AbstractServiceRegistryImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public <R extends Service> void stopService(ServiceBinding<R> binding) {
|
||||
public synchronized <R extends Service> void stopService(ServiceBinding<R> binding) {
|
||||
final Service service = binding.getService();
|
||||
if ( Stoppable.class.isInstance( service ) ) {
|
||||
try {
|
||||
|
@ -433,7 +433,7 @@ public abstract class AbstractServiceRegistryImpl
|
|||
/**
|
||||
* Very advanced and tricky to handle: not designed for this. Intended for experiments only!
|
||||
*/
|
||||
public void resetParent(BootstrapServiceRegistry newParent) {
|
||||
public synchronized void resetParent(BootstrapServiceRegistry newParent) {
|
||||
if ( this.parent != null ) {
|
||||
this.parent.deRegisterChild( this );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue