From edad1fb02cba427448d56a7f1b50866208ca6300 Mon Sep 17 00:00:00 2001 From: Yuriy Artamonov Date: Sat, 21 Dec 2024 21:04:02 +0100 Subject: [PATCH] [platform] IJPL-174111 Stop spamming user logs with warnings on development time problems GitOrigin-RevId: 6baeb5b2f47cf95a7d783d30988121889c607e9b --- platform/ide-core/src/com/intellij/util/Alarm.kt | 9 ++++++--- .../intellij/serviceContainer/ComponentManagerImpl.kt | 10 ++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/platform/ide-core/src/com/intellij/util/Alarm.kt b/platform/ide-core/src/com/intellij/util/Alarm.kt index b2090c4ad3ce..fd05d4301b92 100644 --- a/platform/ide-core/src/com/intellij/util/Alarm.kt +++ b/platform/ide-core/src/com/intellij/util/Alarm.kt @@ -12,7 +12,6 @@ import com.intellij.openapi.application.* import com.intellij.openapi.components.Service import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.diagnostic.logger -import com.intellij.openapi.progress.Cancellation import com.intellij.openapi.util.Disposer import com.intellij.openapi.wm.IdeFrame import com.intellij.util.concurrency.ThreadingAssertions @@ -89,8 +88,12 @@ open class Alarm @Internal constructor( @Deprecated("Please use flow or at least pass coroutineScope") constructor() : this(threadToUse = ThreadToUse.SWING_THREAD, parentDisposable = null, activationComponent = null) { - val stackFrames = StackWalker.getInstance().walk { stream -> stream.asSequence().drop(1).firstOrNull()?.toString() } - LOG.warn("Do not create alarm without coroutineScope: $stackFrames") + val application = ApplicationManager.getApplication() + if (application == null || application.isUnitTestMode || application.isInternal) { + val stackFrames = StackWalker.getInstance().walk { stream -> stream.asSequence().drop(1).firstOrNull()?.toString() } ?: "" + // logged only during development, let's not spam users + LOG.warn("Do not create alarm without coroutineScope: $stackFrames") + } } @Internal diff --git a/platform/service-container/src/com/intellij/serviceContainer/ComponentManagerImpl.kt b/platform/service-container/src/com/intellij/serviceContainer/ComponentManagerImpl.kt index 680f320ae3ad..4d9540b3c949 100644 --- a/platform/service-container/src/com/intellij/serviceContainer/ComponentManagerImpl.kt +++ b/platform/service-container/src/com/intellij/serviceContainer/ComponentManagerImpl.kt @@ -16,7 +16,6 @@ import com.intellij.diagnostic.PluginException import com.intellij.diagnostic.StartUpMeasurer import com.intellij.ide.plugins.* import com.intellij.ide.plugins.cl.PluginAwareClassLoader -import com.intellij.idea.AppMode.isDevServer import com.intellij.idea.AppMode.isLightEdit import com.intellij.openapi.Disposable import com.intellij.openapi.application.* @@ -862,8 +861,8 @@ abstract class ComponentManagerImpl( // => but [parentDisposable] is [UsefulTestCase.getTestRootDisposable] which might be disposed after the fixture. // // This indicates a problem with scoping. - // The [parentDisposable] should be disposed on the same level as the code which replaces the service, i.e., - // if the service is registered in a [setUp] method before a test, + // The [parentDisposable] should be disposed on the same level as the code which replaces the service. + // If the service is registered in a [setUp] method before a test, // then the [parentDisposable] should be disposed in [tearDown] right after the test. // In other words, it's generally incorrect to use [UsefulTestCase.getTestRootDisposable] // as a [parentDisposable] for the replacement service. @@ -1065,9 +1064,8 @@ abstract class ComponentManagerImpl( LOG.error(PluginException(message, plugin.pluginId)) } else if (!isKnown || !impl.startsWith("com.intellij.")) { - if (ApplicationManager.getApplication().isUnitTestMode - || PluginManagerCore.isRunningFromSources() - || isDevServer()) { + val application = ApplicationManager.getApplication() + if (application == null || application.isUnitTestMode || application.isInternal) { // logged only during development, let's not spam users LOG.warn(message) }