Throw exception if anyone attempts to open "/" bundle resource. (FELIX-2832)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1068923 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java b/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
index 5a3df7b..f5bddb8 100644
--- a/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
+++ b/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
@@ -47,6 +47,17 @@
         throws IOException
     {
         super(url);
+
+        // If this is an attempt to create a connection to the root of
+        // the bundle, then throw an exception since this isn't possible.
+        // We only allow "/" as a valid URL so it can be used as context
+        // for creating other URLs.
+        String path = url.getPath();
+        if ((path == null) || (path.length() == 0) || path.equals("/"))
+        {
+            throw new IOException("Resource does not exist: " + url);
+        }
+
         m_framework = framework;
 
         // If we don't have a framework instance, try to find