Skip to content

Commit 431be1b

Browse files
MatanZNadeem Anwar
authored andcommitted
Copy the set of keys from the map before iterating.
To avoid removing elements from the map while iterating over it. This should solve the Concurrent Modification Exception in the bitmap garbage collection.
1 parent cca2259 commit 431be1b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

terminal-emulator/src/main/java/com/termux/terminal/TerminalBuffer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,8 @@ public void bitmapGC(int timeDelta) {
616616
}
617617
}
618618
}
619-
for (Integer bn: bitmaps.keySet()) {
619+
Set<Integer> keys = new HashSet<Integer>(bitmaps.keySet());
620+
for (Integer bn: keys) {
620621
if (!used.contains(bn)) {
621622
bitmaps.remove(bn);
622623
}

0 commit comments

Comments
 (0)