get PCE stackframe back to enable sensible stacktraces

This commit is contained in:
Alexey Kudravtsev
2015-03-23 14:11:53 +03:00
parent 637b61efcf
commit 01f2236812
2 changed files with 9 additions and 19 deletions
@@ -28,7 +28,10 @@ import com.intellij.openapi.util.EmptyRunnable;
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
import com.intellij.testFramework.LightPlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.*;
import com.intellij.util.Alarm;
import com.intellij.util.Function;
import com.intellij.util.Processor;
import com.intellij.util.ThrowableRunnable;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.DoubleArrayList;
import com.intellij.util.containers.Stack;
@@ -46,18 +49,16 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @author yole
*/
public class ProgressIndicatorTest extends LightPlatformTestCase {
public void testCheckCanceledHasNoStackFrame() {
ProgressIndicatorBase pib = new ProgressIndicatorBase();
public void testCheckCanceledHasStackFrame() {
ProgressIndicator pib = new ProgressIndicatorBase();
pib.cancel();
try {
pib.checkCanceled();
fail("Please restore ProgressIndicatorBase.checkCanceled() check!");
}
catch(ProcessCanceledException ex) {
boolean isInternal = SystemProperties.getBooleanProperty("idea.is.internal", false);
boolean isTest = SystemProperties.getBooleanProperty("idea.is.unit.test", false);
boolean hasStackFrame = ex.getStackTrace().length != 0;
assertTrue("Should have no stackframe", (isInternal || isTest) == hasStackFrame);
assertTrue("Should have stackframe", hasStackFrame);
}
}
@@ -15,24 +15,13 @@
*/
package com.intellij.openapi.progress;
import com.intellij.util.SystemProperties;
import org.jetbrains.annotations.NotNull;
public class ProcessCanceledException extends RuntimeException {
private static final boolean ourHasStackTraces = SystemProperties.getBooleanProperty("idea.is.internal", false) || SystemProperties.getBooleanProperty("idea.is.unit.test", false);
public ProcessCanceledException() {
}
public ProcessCanceledException(Throwable cause) {
public ProcessCanceledException(@NotNull Throwable cause) {
super(cause);
}
@Override
public Throwable fillInStackTrace() {
if (ourHasStackTraces) return super.fillInStackTrace();
// https://wikis.oracle.com/display/HotSpotInternals/PerformanceTechniques
// http://www.javaspecialists.eu/archive/Issue129.html
// http://java-performance.info/throwing-an-exception-in-java-is-very-slow/
return this;
}
}