fixes for occasional JUnit failures when indexing job starts during shutdown
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/TaglibController.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/TaglibController.java
index f5cf363..887a164 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/TaglibController.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/TaglibController.java
@@ -178,6 +178,7 @@
}
static TaglibController _instance = null;
+ static private boolean fIsShutdown = false;
public static ITextFileBuffer getFileBuffer(IDocument document) {
synchronized (_instance.fDocumentMap) {
@@ -218,14 +219,16 @@
}
}
- public static void shutdown() {
+ public synchronized static void shutdown() {
+ setShutdown(true);
FileBuffers.getTextFileBufferManager().removeFileBufferListener(_instance.fBufferListener);
_instance = null;
}
- public static void startup() {
+ public synchronized static void startup() {
_instance = new TaglibController();
FileBuffers.getTextFileBufferManager().addFileBufferListener(_instance.fBufferListener);
+ setShutdown(false);
}
IFileBufferListener fBufferListener;
@@ -248,9 +251,22 @@
* @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
*/
public void setup(IDocument document) {
+ // if we've already shutdown, just ignore
+ if (isShutdown()) return;
synchronized (_instance.fJSPdocuments) {
_instance.fJSPdocuments.add(document);
}
}
+ private static synchronized boolean isShutdown() {
+ return fIsShutdown;
+ }
+
+
+ private static synchronized void setShutdown(boolean isShutdown) {
+ fIsShutdown = isShutdown;
+ }
+
+
+
}
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
index bbfcdd0..8bd5363 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
@@ -169,8 +169,14 @@
}
catch (NullPointerException e) {
// logging this exception that I've seen a couple of times...
- System.out.println(e);
+ // seems to happen during shutdown of unit tests, at which
+ // point Logger has already been unloaded
+ try {
Logger.logException("XMLJSPRegionHelper: exception in node parsing", e); //$NON-NLS-1$
+ }
+ catch (NoClassDefFoundError ex) {
+ // do nothing, since we're just ending
+ }
}
}