Author: cziegeler Date: Tue Jul 16 09:36:48 2013 New Revision: 1503632 URL: http://svn.apache.org/r1503632 Log: SLING-2966 : Insufficient synchronization in SlingAuthenticator
Modified: sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java Modified: sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java?rev=1503632&r1=1503631&r2=1503632&view=diff ============================================================================== --- sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java (original) +++ sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java Tue Jul 16 09:36:48 2013 @@ -1468,30 +1468,28 @@ public class SlingAuthenticator implemen this.authenticator = authenticator; } - public void serviceChanged(ServiceEvent event) { - - // modification of service properties, unregistration of the - // service or service properties does not contain requirements - // property any longer (new event with type 8 added in OSGi Core - // 4.2) - if ((event.getType() & (ServiceEvent.MODIFIED - | ServiceEvent.UNREGISTERING | 8)) != 0) { - removeService(event.getServiceReference()); - } + public void serviceChanged(final ServiceEvent event) { + synchronized ( props ) { + // modification of service properties, unregistration of the + // service or service properties does not contain requirements + // property any longer (new event with type 8 added in OSGi Core + // 4.2) + if ((event.getType() & (ServiceEvent.MODIFIED + | ServiceEvent.UNREGISTERING | 8)) != 0) { + removeService(event.getServiceReference()); + } - // add requirements for newly registered services and for - // updated services - if ((event.getType() & (ServiceEvent.REGISTERED | ServiceEvent.MODIFIED)) != 0) { - addService(event.getServiceReference()); + // add requirements for newly registered services and for + // updated services + if ((event.getType() & (ServiceEvent.REGISTERED | ServiceEvent.MODIFIED)) != 0) { + addService(event.getServiceReference()); + } } } void registerServices() { AuthenticationRequirementHolder[][] authReqsList; - synchronized (props) { - authReqsList = props.values().toArray( - new AuthenticationRequirementHolder[props.size()][]); - } + authReqsList = props.values().toArray(new AuthenticationRequirementHolder[props.size()][]); for (AuthenticationRequirementHolder[] authReqs : authReqsList) { registerService(authReqs); @@ -1517,19 +1515,13 @@ public class SlingAuthenticator implemen } final AuthenticationRequirementHolder[] authReqs = authReqList.toArray(new AuthenticationRequirementHolder[authReqList.size()]); - registerService(authReqs); - synchronized (props) { - props.put(ref.getProperty(Constants.SERVICE_ID), authReqs); - } + registerService(authReqs); + props.put(ref.getProperty(Constants.SERVICE_ID), authReqs); } private void removeService(final ServiceReference ref) { - final AuthenticationRequirementHolder[] authReqs; - synchronized (props) { - authReqs = props.remove(ref.getProperty(Constants.SERVICE_ID)); - } - + final AuthenticationRequirementHolder[] authReqs = props.remove(ref.getProperty(Constants.SERVICE_ID)); if (authReqs != null) { for (AuthenticationRequirementHolder authReq : authReqs) { authenticator.authRequiredCache.removeHolder(authReq);