HHH-10427 - Fix ServiceRegistry creates multiple service instances and returns uninitialized services

This commit is contained in:
Andrea Boriero 2016-04-18 10:09:53 +01:00 committed by Steve Ebersole
parent 493793a299
commit c1fde98aee
1 changed files with 6 additions and 5 deletions

View File

@ -183,7 +183,7 @@ public abstract class AbstractServiceRegistryImpl
if ( serviceBinding == null ) { if ( serviceBinding == null ) {
throw new UnknownServiceException( serviceRole ); throw new UnknownServiceException( serviceRole );
} }
synchronized (this) {
R service = serviceBinding.getService(); R service = serviceBinding.getService();
if ( service == null ) { if ( service == null ) {
service = initializeService( serviceBinding ); service = initializeService( serviceBinding );
@ -191,6 +191,7 @@ public abstract class AbstractServiceRegistryImpl
return service; return service;
} }
}
protected <R extends Service> void registerService(ServiceBinding<R> serviceBinding, R service) { protected <R extends Service> void registerService(ServiceBinding<R> serviceBinding, R service) {
serviceBinding.setService( service ); serviceBinding.setService( service );