From 9185e79e7bfab9b1865c0353c46af7b672fb03b2 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Mon, 4 May 2020 21:17:04 +0300 Subject: [PATCH] reuse CompoundRuntimeException#throwIfNotEmpty GitOrigin-RevId: a46fb3076e649f93c3bd793a2a2353f7dc78f5e2 --- .../util/messages/impl/MessageBusImpl.java | 23 ++----------------- .../util/lang/CompoundRuntimeException.java | 6 +++++ 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/platform/core-api/src/com/intellij/util/messages/impl/MessageBusImpl.java b/platform/core-api/src/com/intellij/util/messages/impl/MessageBusImpl.java index 5e0a93a1ce2a..4137697d9e6e 100644 --- a/platform/core-api/src/com/intellij/util/messages/impl/MessageBusImpl.java +++ b/platform/core-api/src/com/intellij/util/messages/impl/MessageBusImpl.java @@ -9,7 +9,6 @@ import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.util.Disposer; import com.intellij.util.ArrayUtil; import com.intellij.util.EventDispatcher; -import com.intellij.util.ExceptionUtil; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.lang.CompoundRuntimeException; @@ -431,23 +430,7 @@ public class MessageBusImpl implements MessageBus { } } - if (exceptions != null) { - throwExceptions(exceptions); - } - } - - private static void throwExceptions(@NotNull List exceptions) { - if (exceptions.size() == 1) { - ExceptionUtil.rethrow(exceptions.get(0)); - } - else { - for (Throwable exception : exceptions) { - if (exception instanceof ProcessCanceledException) { - throw (ProcessCanceledException)exception; - } - } - throw new CompoundRuntimeException(exceptions); - } + CompoundRuntimeException.throwIfNotEmpty(exceptions); } private @Nullable List deliverMessage(@NotNull Message job, @@ -611,9 +594,7 @@ public class MessageBusImpl implements MessageBus { exceptions = deliverMessage(job, jobQueue, myMessageDeliveryListener, exceptions); } - if (exceptions != null) { - throwExceptions(exceptions); - } + CompoundRuntimeException.throwIfNotEmpty(exceptions); } public final void setMessageDeliveryListener(@Nullable MessageDeliveryListener listener) { diff --git a/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java b/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java index 22370fcb304a..f429fb829688 100644 --- a/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java +++ b/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java @@ -1,6 +1,7 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.util.lang; +import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.util.Consumer; import com.intellij.util.EmptyConsumer; import com.intellij.util.ExceptionUtil; @@ -106,6 +107,11 @@ public final class CompoundRuntimeException extends RuntimeException { ExceptionUtil.rethrow(throwables.get(0)); } else { + for (Throwable th : throwables) { + if (th instanceof ProcessCanceledException) { + throw (ProcessCanceledException)th; + } + } throw new CompoundRuntimeException(throwables); } }