Skip to content
Permalink
Browse files

Merge pull request #12249 from pferraro/singleton

WFLY-12022 Concurrent singleton service installation can cause service to run simultaneously on 2 members
  • Loading branch information
kabir committed Apr 29, 2019
2 parents 7a1fe2f + b8266e5 commit 64896f1500fe465ad83d96ede9fa19d0c3747f18
@@ -81,7 +81,7 @@
* all of which share the same {@link Cache} instance.
* @author Paul Ferraro
*/
@org.infinispan.notifications.Listener(sync = false)
@org.infinispan.notifications.Listener
public class CacheServiceProviderRegistry<T> implements ServiceProviderRegistry<T>, GroupListener, AutoCloseable {

private static ThreadFactory createThreadFactory(Class<?> targetClass) {
@@ -98,7 +98,7 @@ public void stop(StopContext context) {
}

@Override
public void providersChanged(Set<Node> nodes) {
public synchronized void providersChanged(Set<Node> nodes) {
Group group = this.registry.get().getGroup();
List<Node> candidates = new ArrayList<>(group.getMembership().getMembers());
candidates.retainAll(nodes);
@@ -159,15 +159,15 @@ public void providersChanged(Set<Node> nodes) {
}

@Override
public void start() {
public synchronized void start() {
// If we were not already the primary node
if (this.primary.compareAndSet(false, true)) {
this.primaryLifecycle.start();
}
}

@Override
public void stop() {
public synchronized void stop() {
// If we were the previous the primary node
if (this.primary.compareAndSet(true, false)) {
this.primaryLifecycle.stop();

0 comments on commit 64896f1

Please sign in to comment.
You can’t perform that action at this time.