From 5f6738063e155ba026a1e11d45f624aebe371924 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 12 Feb 2026 14:08:08 +0100 Subject: [PATCH] IJPL-233509 [platform] simpler marking for auto-submitted reports ...; pointless coroutine nesting in `ITNReporter` GitOrigin-RevId: c453b73742235a3c14c48b8bfaee57602b116246 --- .../diagnostic/ExceptionAutoReportUtil.kt | 24 +-------------- .../com/intellij/diagnostic/ITNReporter.kt | 30 ++++++++----------- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/diagnostic/ExceptionAutoReportUtil.kt b/platform/platform-impl/src/com/intellij/diagnostic/ExceptionAutoReportUtil.kt index 1fb988bbdae8..294c1a8ea1bc 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/ExceptionAutoReportUtil.kt +++ b/platform/platform-impl/src/com/intellij/diagnostic/ExceptionAutoReportUtil.kt @@ -11,8 +11,6 @@ import com.intellij.ide.util.PropertiesComponent import com.intellij.idea.AppMode import com.intellij.internal.statistic.utils.getPluginInfoByDescriptor import com.intellij.openapi.application.impl.ApplicationInfoImpl -import com.intellij.openapi.diagnostic.Attachment -import com.intellij.openapi.diagnostic.IdeaLoggingEvent import com.intellij.openapi.diagnostic.thisLogger import com.intellij.openapi.project.Project import com.intellij.openapi.startup.ProjectActivity @@ -90,27 +88,7 @@ object ExceptionAutoReportUtil { return Pair(submitter, plugin) } - private fun isDefaultSubmitter(submitter: ITNReporter): Boolean { - return submitter.javaClass == ITNReporter::class.java - } - - private interface PlatformAutoReportedExceptionMarker - - /** - * Used to distinguish exceptions from the platform reported by [ITNReporter]. - * Don't mix with other product-level auto-report systems. - */ - fun createPlatformAutoReportedEvent( - message: String?, - throwable: Throwable, - attachments: List, - plugin: IdeaPluginDescriptor?, - data: Any?, - ): IdeaLoggingEvent { - return object : IdeaLoggingEvent(message, throwable, attachments, plugin, data), PlatformAutoReportedExceptionMarker {} - } - - fun isPlatformAutoReportedEvent(event: IdeaLoggingEvent): Boolean = event is PlatformAutoReportedExceptionMarker + private fun isDefaultSubmitter(submitter: ITNReporter): Boolean = submitter.javaClass == ITNReporter::class.java } internal class ReporterIdForEAAutoReporters : AboutPopupDescriptionProvider { diff --git a/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.kt b/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.kt index 0a75b6ba368d..d90da6948cfc 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.kt +++ b/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.kt @@ -24,7 +24,6 @@ import com.intellij.platform.ide.progress.withBackgroundProgress import com.intellij.util.Consumer import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.async import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.jetbrains.annotations.ApiStatus @@ -57,23 +56,21 @@ open class ITNReporter internal constructor(private val postUrl: String) : Error parentComponent: Component, consumer: Consumer ): Boolean { - val errorBean = createReportBean(events[0], additionalInfo) + val errorBean = createReportBean(events[0], additionalInfo, autoReported = false) val project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(parentComponent)) return submit(project, errorBean, parentComponent, consumer::consume) } @ApiStatus.Internal suspend fun submitAutomated(event: IdeaLoggingEvent): SubmittedReportInfo { - val errorBean = createReportBean(event, comment = "Automatically reported exception") - return service().coroutineScope.async { - try { - val reportId = ITNProxy.sendError(errorBean, postUrl) - SubmittedReportInfo(ITNProxy.getBrowseUrl(reportId), reportId.toString(), SubmittedReportInfo.SubmissionStatus.NEW_ISSUE) - } - catch (_: Exception) { - SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.FAILED) - } - }.await() + val errorBean = createReportBean(event, comment = "Automatically reported exception", autoReported = true) + return try { + val reportId = ITNProxy.sendError(errorBean, postUrl) + SubmittedReportInfo(ITNProxy.getBrowseUrl(reportId), reportId.toString(), SubmittedReportInfo.SubmissionStatus.NEW_ISSUE) + } + catch (_: Exception) { + SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.FAILED) + } } /** @@ -81,11 +78,10 @@ open class ITNReporter internal constructor(private val postUrl: String) : Error */ open fun showErrorInRelease(event: IdeaLoggingEvent): Boolean = false - private fun createReportBean(event: IdeaLoggingEvent, comment: String?): ErrorBean = - ErrorBean(event, comment, - event.plugin?.pluginId?.idString, event.plugin?.name, event.plugin?.version, - IdeaLogger.ourLastActionId, - ExceptionAutoReportUtil.isPlatformAutoReportedEvent(event)) + private fun createReportBean(event: IdeaLoggingEvent, comment: String?, autoReported: Boolean) = ErrorBean( + event, comment, event.plugin?.pluginId?.idString, event.plugin?.name, event.plugin?.version, + IdeaLogger.ourLastActionId, autoReported + ) private fun submit( project: Project?,