[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
This commit is contained in:
Roman Shevchenko
2024-10-25 19:34:35 +02:00
committed by intellij-monorepo-bot
parent ea62ea04bc
commit 9e712d54a2

View File

@@ -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() {