[terminal] IJPL-233039 Use soft assertion on TerminalUtil.hasRunningCommands

A lot of external plugins use it, so we can't just start throwing exception here.

GitOrigin-RevId: 7c7ae753a1c6c04f8a1cf72e023ac5105a1a4914
This commit is contained in:
Konstantin Hudyakov
2026-02-05 15:16:38 +00:00
committed by intellij-monorepo-bot
parent 6d637c4c38
commit ab4a557c86
5 changed files with 26 additions and 6 deletions
+2
View File
@@ -1745,6 +1745,8 @@ com.intellij.util.QueryExecutor
com.intellij.util.QueryParameters
- getProject():com.intellij.openapi.project.Project
- isQueryValid():Z
f:com.intellij.util.concurrency.ThreadingAssertions
- s:softAssertNoReadAccess():V
com.intellij.util.download.DownloadableFileDescription
- a:generateFileName(com.intellij.openapi.util.Condition):java.lang.String
- a:getDefaultFileName():java.lang.String
@@ -178,6 +178,19 @@ public final class ThreadingAssertions {
}
}
/**
* Asserts that the current thread has <b>no</b> read access <b>without throwing</b> an exception.
*
* @see com.intellij.util.concurrency.annotations.RequiresReadLockAbsence
*/
@Obsolete
public static void softAssertNoReadAccess() {
Application application = ApplicationManager.getApplication();
if (application != null && application.isReadAccessAllowed()) {
getLogger().error(createThreadAccessException(MUST_NOT_EXECUTE_IN_READ_ACTION));
}
}
/**
* Asserts that the current thread has <b>no</b> read access local to this thread (non-inherited).
*/
@@ -78,8 +78,8 @@ interface TerminalWidget : ComponentContainer {
* so it is prohibited to call it on EDT or under read action.
*/
@ApiStatus.Experimental
@RequiresReadLockAbsence
@RequiresBackgroundThread
@RequiresReadLockAbsence(generateAssertion = false)
@RequiresBackgroundThread(generateAssertion = false)
fun isCommandRunning(): Boolean {
return false
}
@@ -207,8 +207,8 @@ public class ShellTerminalWidget extends JBTerminalWidget implements TerminalPan
* so it is prohibited to call it on EDT or under read action.
*/
@Override
@RequiresReadLockAbsence
@RequiresBackgroundThread
@RequiresReadLockAbsence(generateAssertion = false)
@RequiresBackgroundThread(generateAssertion = false)
public boolean hasRunningCommands() throws IllegalStateException {
TtyConnector connector = getTtyConnector();
if (connector == null) return false;
@@ -12,6 +12,7 @@ import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.remote.RemoteSshProcess;
import com.intellij.ui.ExperimentalUI;
import com.intellij.util.concurrency.ThreadingAssertions;
import com.intellij.util.concurrency.annotations.RequiresBackgroundThread;
import com.intellij.util.concurrency.annotations.RequiresReadLockAbsence;
import com.intellij.util.containers.ContainerUtil;
@@ -44,9 +45,13 @@ public final class TerminalUtil {
* This method may access the file system and launch external processes,
* so it is prohibited to call it on EDT or under read action.
*/
@RequiresReadLockAbsence
@RequiresBackgroundThread
@SuppressWarnings("UsagesOfObsoleteApi") // Can't use just only annotations because they generate throwing assertions
@RequiresReadLockAbsence(generateAssertion = false)
@RequiresBackgroundThread(generateAssertion = false)
public static boolean hasRunningCommands(@NotNull TtyConnector connector) throws IllegalStateException {
ThreadingAssertions.softAssertBackgroundThread();
ThreadingAssertions.softAssertNoReadAccess();
if (!connector.isConnected()) return false;
ProcessTtyConnector processTtyConnector = ShellTerminalWidget.getProcessTtyConnector(connector);
if (processTtyConnector == null) return true;