Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvladt2011-03-14 15:26:49 -0400
committervladt2011-03-14 15:27:11 -0400
commitf7eae26ad0736627b354415e6862b94a6c8c2b92 (patch)
tree08675039cbd8acd9a544d0d45127cb132a258861 /org.eclipse.m2e.logback.configuration/src
parente26726c91912fcfefc8aa28d0c8dabfa9c4aac92 (diff)
downloadm2e-core-f7eae26ad0736627b354415e6862b94a6c8c2b92.tar.gz
m2e-core-f7eae26ad0736627b354415e6862b94a6c8c2b92.tar.xz
m2e-core-f7eae26ad0736627b354415e6862b94a6c8c2b92.zip
Don't show misleading message "org.eclipse.core.runtime.AssertionFailedException: assertion failed: The application has not been initialized." when configuring logback
Diffstat (limited to 'org.eclipse.m2e.logback.configuration/src')
-rw-r--r--org.eclipse.m2e.logback.configuration/src/org/eclipse/m2e/logback/configuration/LogPlugin.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/org.eclipse.m2e.logback.configuration/src/org/eclipse/m2e/logback/configuration/LogPlugin.java b/org.eclipse.m2e.logback.configuration/src/org/eclipse/m2e/logback/configuration/LogPlugin.java
index cf3599d0..119860ed 100644
--- a/org.eclipse.m2e.logback.configuration/src/org/eclipse/m2e/logback/configuration/LogPlugin.java
+++ b/org.eclipse.m2e.logback.configuration/src/org/eclipse/m2e/logback/configuration/LogPlugin.java
@@ -29,6 +29,8 @@ import ch.qos.logback.classic.util.ContextInitializer;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.StatusPrinter;
+import org.eclipse.core.internal.runtime.Messages;
+import org.eclipse.core.runtime.AssertionFailedException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
@@ -53,10 +55,22 @@ public class LogPlugin extends Plugin {
private TimerTask timerTask = new TimerTask() {
@SuppressWarnings("synthetic-access")
public void run() {
- if(Platform.getInstanceLocation().isSet()) {
- timer.cancel();
- configureLogback();
+ try {
+ if(!Platform.isRunning() || !Platform.getInstanceLocation().isSet()) {
+ return;
+ }
+ } catch(AssertionFailedException e) {
+ String message = Messages.meta_appNotInit;
+ if(e.getMessage() != null && e.getMessage().indexOf(message) >= 0) {
+ // That's ok, the instance location was not initialized yet
+ return;
+ }
+ throw e;
}
+
+ // The instance location is set
+ timer.cancel();
+ configureLogback();
}
};
@@ -72,8 +86,14 @@ public class LogPlugin extends Plugin {
return;
}
- if(!Platform.getInstanceLocation().isSet()) {
- systemOut("The " + PLUGIN_ID + " bundle was activated before the platform instance location was initialized."); //$NON-NLS-1$ //$NON-NLS-2$
+ boolean instanceLocationIsSet = false;
+ try {
+ instanceLocationIsSet = Platform.isRunning() && Platform.getInstanceLocation().isSet();
+ } catch(Exception e) {
+ // That's probably ok, the instance location was not initialized yet
+ }
+ if(!instanceLocationIsSet) {
+ systemOut("The " + PLUGIN_ID + " bundle was activated before the platform instance location was initialized. Will retry after the instance location is initialized."); //$NON-NLS-1$ //$NON-NLS-2$
timer.schedule(timerTask, 0 /*delay*/, 50 /*period*/);
} else {
configureLogback();

Back to the top