mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
terminal: close ttyConnector synchronously in tests
GitOrigin-RevId: d167ed211e6276516cf28c5400b20039b1ee99ec
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b157651a8b
commit
95213f24d5
@@ -3,6 +3,7 @@ package org.jetbrains.plugins.terminal.exp
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.DataKey
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.options.advanced.AdvancedSettings
|
||||
import com.intellij.openapi.util.Key
|
||||
@@ -61,16 +62,9 @@ class BlockTerminalSession(settings: JBTerminalSystemSettingsProviderBase,
|
||||
thisLogger().error(t)
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
ttyConnector.close()
|
||||
}
|
||||
catch (t: Throwable) {
|
||||
thisLogger().error(t)
|
||||
}
|
||||
finally {
|
||||
for (terminationListener in terminationListeners) {
|
||||
terminationListener.run()
|
||||
}
|
||||
ttyConnector.closeSafely()
|
||||
for (terminationListener in terminationListeners) {
|
||||
terminationListener.run()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,12 +91,26 @@ class BlockTerminalSession(settings: JBTerminalSystemSettingsProviderBase,
|
||||
commandManager.addListener(listener, parentDisposable)
|
||||
}
|
||||
|
||||
private fun TtyConnector.closeSafely() {
|
||||
try {
|
||||
this.close()
|
||||
}
|
||||
catch (t: Throwable) {
|
||||
thisLogger().error("Error closing TtyConnector", t)
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
// Complete to avoid memory leaks with hanging callbacks. If already completed, nothing will change.
|
||||
terminalStarterFuture.complete(null)
|
||||
terminalStarterFuture.getNow(null)?.let {
|
||||
it.requestEmulatorStop()
|
||||
it.close()
|
||||
if (ApplicationManager.getApplication().isUnitTestMode) {
|
||||
it.ttyConnector.closeSafely() // close synchronously
|
||||
}
|
||||
else {
|
||||
it.close() // close in background thread
|
||||
}
|
||||
}
|
||||
executorServiceManager.shutdownWhenAllExecuted()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user