Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FELIX-6066] Prevent duplicate activation of ConfigurationManager #185

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ public void run()
{
deactivate();
}
activate(holder.getPersistenceManager());
if (!holder.isActivated()) {
activate(holder.getPersistenceManager());
holder.activate();
}
}
});
}
Expand All @@ -197,7 +200,7 @@ public void modifiedService(final ServiceReference<PersistenceManager> reference
this.holders.remove(holder);
this.holders.add(new Holder(reference, holder.getPersistenceManager()));
Collections.sort(this.holders);
if ( holders.get(0) == holder && oldHolder.compareTo(holder) != 0 )
if ( holders.get(0) == holder && oldHolder != null && oldHolder.compareTo(holder) != 0 )
{
this.workerQueue.enqueue(new Runnable()
{
Expand All @@ -206,7 +209,10 @@ public void modifiedService(final ServiceReference<PersistenceManager> reference
public void run()
{
deactivate();
activate(holder.getPersistenceManager());
if (!holder.isActivated()) {
activate(holder.getPersistenceManager());
holder.activate();
}
}
});
}
Expand Down Expand Up @@ -234,7 +240,11 @@ public void run()
deactivate();
if ( !holders.isEmpty() )
{
activate(holders.get(0).getPersistenceManager());
Holder h = holders.get(0);
if (!h.isActivated()) {
activate(h.getPersistenceManager());
h.activate();
}
}
}
});
Expand All @@ -248,6 +258,9 @@ public static final class Holder implements Comparable<Holder>

private final ExtPersistenceManager manager;

// no need to synchronize, as it's changed only in WorkQueue tasks
private boolean activated;

public Holder(final ServiceReference<PersistenceManager> ref, final ExtPersistenceManager epm)
{
this.reference = ref;
Expand All @@ -266,6 +279,14 @@ public int compareTo(final Holder o)
return -reference.compareTo(o.reference);
}

public boolean isActivated() {
return activated;
}

public void activate() {
this.activated = true;
}

@Override
public int hashCode()
{
Expand Down