Bug 477243 - Handle NullPointerException in getURLConverter

When getURLConverter is called after the bundle has been shut down,
a NullPointerException is generated because getBundleContext returns
null. Handle this by explicitly testing the bundle context and return
early instead of causing a NullPointerException.

Change-Id: Ia3312d3255a054154947d56de8c3478a00804364
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
index 19a35eb..355ba8a 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
@@ -315,6 +315,10 @@
 	 * find one.
 	 */
 	public static URLConverter getURLConverter(URL url) {
+		BundleContext ctx = getContext();
+		if (url == null || ctx == null) {
+			return null;
+		}
 		String protocol = url.getProtocol();
 		synchronized (urlTrackers) {
 			ServiceTracker<Object, URLConverter> tracker = urlTrackers.get(protocol);
@@ -324,7 +328,7 @@
 				String FILTER_POSTFIX = "))"; //$NON-NLS-1$
 				Filter filter = null;
 				try {
-					filter = getContext().createFilter(FILTER_PREFIX + protocol + FILTER_POSTFIX);
+					filter = ctx.createFilter(FILTER_PREFIX + protocol + FILTER_POSTFIX);
 				} catch (InvalidSyntaxException e) {
 					return null;
 				}