Skip to content

Commit

Permalink
fix(android): fix ConcurrentModificationException in AdamAndroidDevice
Browse files Browse the repository at this point in the history
Closes #882
  • Loading branch information
Malinskiy committed Jan 23, 2024
1 parent 953ad17 commit ac8d57f
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import kotlinx.coroutines.withContext
import java.awt.image.BufferedImage
import java.io.File
import java.time.Duration
import java.util.concurrent.CopyOnWriteArrayList
import kotlin.coroutines.CoroutineContext
import com.malinskiy.marathon.android.model.ShellCommandResult as MarathonShellCommandResult

Expand Down Expand Up @@ -345,18 +346,14 @@ class AdamAndroidDevice(
}
}

private val logcatListeners = mutableListOf<LineListener>()
private val logcatListeners = CopyOnWriteArrayList<LineListener>()

override fun addLineListener(listener: LineListener) {
synchronized(logcatListeners) {
logcatListeners.add(listener)
}
logcatListeners.add(listener)
}

override fun removeLineListener(listener: LineListener) {
synchronized(logcatListeners) {
logcatListeners.remove(listener)
}
logcatListeners.remove(listener)
}

override suspend fun safeStartScreenRecorder(
Expand Down

0 comments on commit ac8d57f

Please sign in to comment.