Skip to content

Commit 5cc2c9a

Browse files
committed
fix: lock onTermuxSessionExited removal and use session snapshot for working-dir lookup to keep getTermuxSessionsListSnapshot consistent and avoid concurrent-modification races
1 parent 06c0ec6 commit 5cc2c9a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎termux/termux-app/src/main/java/com/termux/app/TermuxActivity.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ public void onServiceConnected(ComponentName componentName, IBinder service) {
469469
} else {
470470

471471
final Optional<TermuxSession> existingSession = workingDir == null ? Optional.empty() :
472-
mTermuxService.getTermuxSessions().stream().filter(session -> Objects.equals(
472+
mTermuxService.getTermuxSessionsListSnapshot().stream().filter(session -> Objects.equals(
473473
session.getTerminalSession().getCwd(), workingDir)).findFirst();
474474

475475
setupTermuxSessionOnServiceConnected(

‎termux/termux-app/src/main/java/com/termux/app/TermuxService.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ public synchronized int removeTermuxSession(TerminalSession sessionToRemove) {
651651

652652
/** Callback received when a {@link TermuxSession} finishes. */
653653
@Override
654-
public void onTermuxSessionExited(final TermuxSession termuxSession) {
654+
public synchronized void onTermuxSessionExited(final TermuxSession termuxSession) {
655655
if (termuxSession != null) {
656656
ExecutionCommand executionCommand = termuxSession.getExecutionCommand();
657657

0 commit comments

Comments
 (0)