Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2017-04-06 09:23:10 +0000
committerPierre-Charles David2017-04-18 09:01:29 +0000
commit0f1a2f4511ca1988dd33ce18e1f24323b5097f1e (patch)
tree454cdfc96e4441c92158c6f313f9cddd8c27bcc2
parent8a3e59fa6485d47ceae53f2d8d7d36ef6b362d4b (diff)
downloadorg.eclipse.sirius-0f1a2f4511ca1988dd33ce18e1f24323b5097f1e.tar.gz
org.eclipse.sirius-0f1a2f4511ca1988dd33ce18e1f24323b5097f1e.tar.xz
org.eclipse.sirius-0f1a2f4511ca1988dd33ce18e1f24323b5097f1e.zip
[514849] Avoid logging the exact same error multiple successive times
Bug: 514849 Change-Id: Ieb7b0c66763c8eca0c029143d0c2f57b28753837 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/LogThroughActiveDialectEditorLogListener.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/LogThroughActiveDialectEditorLogListener.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/LogThroughActiveDialectEditorLogListener.java
index 2375d9069e..7eab9a6b8a 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/LogThroughActiveDialectEditorLogListener.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/LogThroughActiveDialectEditorLogListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2016 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2012, 2017 THALES GLOBAL SERVICES and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.sirius.ui.business.internal.dialect;
+import java.lang.ref.SoftReference;
import java.text.MessageFormat;
import org.eclipse.core.runtime.ILogListener;
@@ -56,14 +57,30 @@ public final class LogThroughActiveDialectEditorLogListener implements ILogListe
*/
private ICommonLabelProvider labelProvider;
+ /**
+ * Remembers the last error logged to avoid repeated notifications. Use a
+ * soft reference to avoid leaks as the log listener is a global singleton,
+ * and some exceptions may have references to large application-level
+ * objects.
+ */
+ private SoftReference<Throwable> previousError;
+
private LogThroughActiveDialectEditorLogListener() {
}
@Override
public void logging(IStatus status, String plugin) {
- boolean hasBeenLoggedThroughDialect = false;
// Always consider final cause of exception
final Throwable exception = getFinalCause(status);
+ synchronized (this) {
+ if (previousError != null && previousError.get() == exception) {
+ // Ignore direct repetitions of the exact same exception, which can
+ // happen when multiple code paths log the same cause.
+ return;
+ }
+ previousError = new SoftReference<>(exception);
+ }
+ boolean hasBeenLoggedThroughDialect = false;
// Step 1: check preferences (should indicate that errors should be
// logged through a pop-up)
if (SiriusEditPlugin.getPlugin().getPreferenceStore().getBoolean(SiriusUIPreferencesKeys.PREF_REACT_TO_PERMISSION_ISSUES_BY_GRAPHICAL_DISPLAY.name())) {

Back to the top