From d5b939b7bec1eaed6ac3f052e3269b4a35c36302 Mon Sep 17 00:00:00 2001 From: Nicolay Mitropolsky Date: Mon, 2 Aug 2021 12:59:34 +0300 Subject: [PATCH] Revert "FlakyTestLogger for debugging the `SpringIntentionsTest`" because it is no mo necessary, tests were fixed in 3ed4fbf7f0609825de13c77ee4d0fec151c0cc3e This reverts commit d9e4cd35e5dc70beb146b6f566a6300df4fc1ac7. This reverts commit 1130715be3508cbaab8579dbbc8193e5713dfa9d. GitOrigin-RevId: fb61c983ed5fa84cd7658e47d875aa6d1ad26e75 --- .../intellij/testFramework/FlakyTestLogger.kt | 63 ------------------- .../util/xml/impl/DomInvocationHandler.java | 13 +--- .../impl/IndexedElementInvocationHandler.java | 5 -- 3 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 platform/platform-api/src/com/intellij/testFramework/FlakyTestLogger.kt diff --git a/platform/platform-api/src/com/intellij/testFramework/FlakyTestLogger.kt b/platform/platform-api/src/com/intellij/testFramework/FlakyTestLogger.kt deleted file mode 100644 index 4fd00e5abf11..000000000000 --- a/platform/platform-api/src/com/intellij/testFramework/FlakyTestLogger.kt +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.intellij.testFramework - -import com.intellij.concurrency.ConcurrentCollectionFactory -import com.intellij.openapi.Disposable -import com.intellij.openapi.util.Disposer -import com.intellij.openapi.util.Key -import org.jetbrains.annotations.TestOnly -import java.io.PrintWriter -import java.io.StringWriter - -@Deprecated("this class is here only for debugging a flaky test, it will be deleted as soon problem will be resolved") -class FlakyTestLogger(val enabled: Boolean) : Disposable { - - - data class Entry(val time: Long, val text: String) - - private val lists = ConcurrentCollectionFactory.createConcurrentIdentitySet>() - - private val lines = ThreadLocal.withInitial { ArrayList().also { lists.add(it) } } - - private fun add(str: String) { - lines.get().add(Entry(System.currentTimeMillis(), """${System.currentTimeMillis()} ${Thread.currentThread().name} $str""")) - } - - override fun dispose() { - lists.flatten().sortedBy { it.time }.forEach { println(it.text) } - } - - fun append(line: String) { - if (!enabled) return - add(line) - } - - fun append(exception: Exception) { - if (!enabled) return - val stringWriter = StringWriter() - exception.printStackTrace(PrintWriter(stringWriter)) - add(stringWriter.toString()) - } - - companion object { - - private val KEY = Key.create("LogAccumulator") - - @JvmStatic - fun get(): FlakyTestLogger? = TestModeFlags.get(KEY) - - @JvmStatic - fun force(): FlakyTestLogger = get() ?: FlakyTestLogger(false) - - @JvmStatic - fun isEnabled(): Boolean = TestModeFlags.get(KEY) != null - - @JvmStatic - @TestOnly - fun enable(disposer: Disposable) { - TestModeFlags.set(KEY, FlakyTestLogger(true).also { Disposer.register(disposer, it) }, disposer) - } - - } - -} \ No newline at end of file diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java index 023cd257e0a5..dd8a0745e155 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java @@ -20,7 +20,6 @@ import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlElement; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; -import com.intellij.testFramework.FlakyTestLogger; import com.intellij.util.*; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xml.*; @@ -656,17 +655,7 @@ public abstract class DomInvocationHandler extends UserDataHolderBase implements @Nullable public final Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { - Invocation invocation = findInvocation(method); - Object r = invocation.invoke(this, args); - FlakyTestLogger log = FlakyTestLogger.get(); - if (log != null && method.getName().equals("exists")) { - log.append("Invocation: for '" + method + "' is '" + invocation + " of " + invocation.getClass() + "' handler = '" + this + - " of " + this.getClass() + "' r = " + r + " of " + ObjectUtils.doIfNotNull(r, Object::getClass)); - if (this instanceof IndexedElementInvocationHandler) { - log.append(((IndexedElementInvocationHandler)this).created); - } - } - return r; + return findInvocation(method).invoke(this, args); } catch (InvocationTargetException ex) { throw ex.getTargetException(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java index 35395eb688e7..1bf552afadb7 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java @@ -20,7 +20,6 @@ import com.intellij.openapi.util.Factory; import com.intellij.psi.xml.XmlElement; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; -import com.intellij.testFramework.FlakyTestLogger; import com.intellij.util.IncorrectOperationException; import com.intellij.util.xml.DomElement; import com.intellij.util.xml.EvaluatedXmlName; @@ -39,8 +38,6 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler { private static final Logger LOG = Logger.getInstance(IndexedElementInvocationHandler.class); private final int myIndex; - public final Exception created; - public IndexedElementInvocationHandler(final EvaluatedXmlName tagName, final FixedChildDescriptionImpl description, final int index, @@ -48,8 +45,6 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler { final DomManagerImpl manager, @Nullable ElementStub stub) { super(description.getType(), strategy, tagName, description, manager, strategy.isPhysical(), stub); - created = FlakyTestLogger.isEnabled() ? new Exception( - "IndexedElementInvocationHandler(" + tagName + ", " + description + ", " + strategy + ", " + index + ", " + stub + ")") : null; myIndex = index; }