From 9e712d54a2e756cf5ccebb15c64b3b4da3656883 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 25 Oct 2024 19:34:35 +0200 Subject: [PATCH] [platform] preventing `SlowOperation` from sticking to the default logger implementation; one last time (IJPL-165118) (cherry picked from commit fdf8d24cde1096d9924fdb98911a2ce6c063ca28) IJ-CR-147772 GitOrigin-RevId: 45c383bf0e81a742b9c92f2fe0b59cfb776d552b --- .../core-api/src/com/intellij/util/SlowOperations.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/core-api/src/com/intellij/util/SlowOperations.java b/platform/core-api/src/com/intellij/util/SlowOperations.java index be493196a7ce..fa12686723f0 100644 --- a/platform/core-api/src/com/intellij/util/SlowOperations.java +++ b/platform/core-api/src/com/intellij/util/SlowOperations.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util; import com.intellij.diagnostic.LoadingState; @@ -30,7 +30,9 @@ import java.util.Set; * @see #assertSlowOperationsAreAllowed() */ public final class SlowOperations { - private static final Logger LOG = Logger.getInstance(SlowOperations.class); + private static final class Holder { + private static final Logger LOG = Logger.getInstance(SlowOperations.class); + } private static final String ERROR_EDT = "Slow operations are prohibited on EDT. See SlowOperations.assertSlowOperationsAreAllowed javadoc."; private static final String ERROR_RA = "Non-cancelable slow operations are prohibited inside read action. See SlowOperations.assertNonCancelableSlowOperationsAreAllowed javadoc."; @@ -109,7 +111,7 @@ public final class SlowOperations { if (isInSection(FORCE_THROW) && !Cancellation.isInNonCancelableSection()) { throw new SlowOperationCanceledException(); } - LOG.error(error); + Holder.LOG.error(error); } /** @@ -123,7 +125,7 @@ public final class SlowOperations { EDT.isCurrentThreadEdt() ? (isSlowOperationAllowed() ? null : ERROR_EDT) : (ApplicationManager.getApplication().isReadAccessAllowed() ? ERROR_RA : null); if (error == null || isAlreadyReported()) return; - LOG.error(error); + Holder.LOG.error(error); } private static boolean isSlowOperationAllowed() {