incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefane...@apache.org
Subject svn commit: r1499977 - /sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java
Date Fri, 05 Jul 2013 12:00:54 GMT
Author: stefanegli
Date: Fri Jul  5 12:00:54 2013
New Revision: 1499977

URL: http://svn.apache.org/r1499977
Log:
SLING-2945 : avoid deadlock in HeartbeatHandler : not using both this and lock as sync objects,
that was not the intention, one sync object is enough and that's the lock object.

Modified:
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java?rev=1499977&r1=1499976&r2=1499977&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/common/heartbeat/HeartbeatHandler.java
Fri Jul  5 12:00:54 2013
@@ -120,7 +120,7 @@ public class HeartbeatHandler implements
     private ComponentContext context;
     
     @Activate
-    protected synchronized void activate(ComponentContext context) {
+    protected void activate(ComponentContext context) {
     	synchronized(lock) {
     		this.context = context;
     		
@@ -161,8 +161,8 @@ public class HeartbeatHandler implements
     public void initialize(final DiscoveryServiceImpl discoveryService,
             final String initialVotingId) {
         this.discoveryService = discoveryService;
-        this.nextVotingId = initialVotingId;
         synchronized(lock) {
+        	this.nextVotingId = initialVotingId;
             issueHeartbeat();
         }
 
@@ -447,11 +447,9 @@ public class HeartbeatHandler implements
         // the currently live instances.
 
         // initiate a new voting
-        String votingId;
-        synchronized (this) {
-            votingId = nextVotingId;
-            nextVotingId = UUID.randomUUID().toString();
-        }
+        String votingId = nextVotingId;
+        nextVotingId = UUID.randomUUID().toString();
+
         VotingView.newVoting(resourceResolver, config, votingId, slingId, liveInstances);
     }
 



Mime
View raw message