Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Fixing concurrent modification bug on linked hash map #61

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
18 changes: 13 additions & 5 deletions scoop/src/main/java/com/lyft/scoop/Scoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.view.View;
import android.view.ViewGroup;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

Expand All @@ -30,17 +31,24 @@ private Scoop(String name, Scoop parent, Map<String, Object> services) {
}

public void destroy() {
for (Map.Entry<String, Scoop> entry : this.children.entrySet()) {
entry.getValue().destroy();
}

this.destroyed = true;
destroyFromParent();

if (parent != null) {
parent.children.remove(this.getName());
}
}

private void destroyFromParent() {
Iterator<Map.Entry<String, Scoop>> iterator = this.children.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Scoop> entry = iterator.next();
entry.getValue().destroyFromParent();
iterator.remove();
}

this.destroyed = true;
}

boolean isDestroyed() {
return destroyed;
}
Expand Down