Add check for NPE.
diff --git a/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/extender/StreamBasedExtenderTests.java b/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/extender/StreamBasedExtenderTests.java
index 9da28ea..9d82c4d 100644
--- a/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/extender/StreamBasedExtenderTests.java
+++ b/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/extender/StreamBasedExtenderTests.java
@@ -3,12 +3,12 @@
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
- * and Apache License v2.0 which accompanies this distribution.
+ * and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
- * and the Apache License v2.0 is available at
+ * and the Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php.
- * You may elect to redistribute this code under either of these licenses.
+ * You may elect to redistribute this code under either of these licenses.
*
* Contributors:
* VMware Inc. - initial contribution
@@ -67,7 +67,7 @@
/**
* This test expects IllegalArgumentException rather than BundleException because for stream based installation the
* exception is thrown when the stream is opened and BundleException is not a valid exception for URL.openStream.
- *
+ *
* @throws BundleException but shouldn't
* @throws Exception possibly
*/
@@ -79,7 +79,7 @@
/**
* This test expects IllegalArgumentException rather than BundleException because for stream based installation the
* exception is thrown when the stream is opened and BundleException is not a valid exception for URL.openStream.
- *
+ *
* @throws BundleException but shouldn't
* @throws Exception possibly
*/
@@ -91,7 +91,7 @@
/**
* This test expects IllegalArgumentException rather than BundleException because for stream based installation the
* exception is thrown when the stream is opened and BundleException is not a valid exception for URL.openStream.
- *
+ *
* @throws BundleException but shouldn't
* @throws Exception possibly
*/
@@ -103,7 +103,7 @@
/**
* This test expects IllegalArgumentException rather than BundleException because for stream based installation the
* exception is thrown when the stream is opened and BundleException is not a valid exception for URL.openStream.
- *
+ *
* @throws BundleException but shouldn't
* @throws Exception possibly
*/
@@ -131,10 +131,14 @@
fail("Unexpected exception " + e.getMessage());
}
- try (InputStream in = url.openStream();) {
- return getBundleContext().installBundle(location, in);
- } catch (IOException e) {
- fail("Unexpected exception " + e.getMessage());
+ if (url != null) {
+ try (InputStream in = url.openStream();) {
+ return getBundleContext().installBundle(location, in);
+ } catch (IOException e) {
+ fail("Unexpected exception " + e.getMessage());
+ return null;
+ }
+ } else {
return null;
}
}