Skip to content
Permalink
Browse files

WFLY-12022 Concurrent singleton service installation can cause servic…

…e to run simultaneously on 2 members.
  • Loading branch information
pferraro committed Apr 27, 2019
1 parent 7a1fe2f commit b8266e58445e98bdd27ab4f4a5f8ffdf1cb5883a
@@ -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 b8266e5

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