Skip to content

Commit

Permalink
Fix #136 remove element from list being parsed
Browse files Browse the repository at this point in the history
Conflicts:
	org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/link/NotifierBase.java
  • Loading branch information
sbordes committed Sep 26, 2014
1 parent 40dbd0c commit 20df623
Showing 1 changed file with 11 additions and 4 deletions.
Expand Up @@ -353,18 +353,25 @@ public void unlisten(final WaveReady<?> linkedObject, final WaveType... waveType
* {@inheritDoc}
*/
@Override
public void unlistenAll(WaveReady<?> linkedObject) throws JRebirthThreadException {
public void unlistenAll(final WaveReady<?> linkedObject) throws JRebirthThreadException {

// This method is called into JIT (all method call are serialized)
// to avoid any thread concurrency trouble
JRebirth.checkJIT();

for (WaveSubscription ws : notifierMap.values()) {
// Iterate over all WaveSubscription
for (final WaveSubscription ws : this.notifierMap.values()) {

for (final WaveHandler wh : ws.getWaveHandlers()) {
for (int i = ws.getWaveHandlers().size() - 1; i >= 0; i--) {
final WaveHandler wh = ws.getWaveHandlers().get(i);
// If the WaveHandler concern the linked object
if (wh.getWaveReady() == linkedObject) {
ws.getWaveHandlers().remove(wh);
// Remove it from registration list
ws.getWaveHandlers().remove(i);
}
}

// If this WaveSubscription doesn't contain any WaveHandler remove the entry.
if (ws.getWaveHandlers().isEmpty()) {
this.notifierMap.remove(ws.getWaveType());
}
Expand Down

0 comments on commit 20df623

Please sign in to comment.