Apply patch to improve exception message. (FELIX-2912)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1101899 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java
index 17a18d0..9a27e3f 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -176,12 +176,14 @@
         bos.close();
     }
 
-    public static void setProxyAuth(URLConnection conn) throws IOException {
+    public static void setProxyAuth(URLConnection conn) throws IOException
+    {
         // Support for http proxy authentication
         String auth = System.getProperty("http.proxyAuth");
         if ((auth != null) && (auth.length() > 0))
         {
-            if ("http".equals(conn.getURL().getProtocol()) || "https".equals(conn.getURL().getProtocol()))
+            if ("http".equals(conn.getURL().getProtocol())
+                || "https".equals(conn.getURL().getProtocol()))
             {
                 String base64 = Base64Encoder.base64Encode(auth);
                 conn.setRequestProperty("Proxy-Authorization", "Basic " + base64);
@@ -190,17 +192,31 @@
 
     }
 
-    public static InputStream openURL(final URL url) throws IOException {
+    public static InputStream openURL(final URL url) throws IOException
+    {
         // Do it the manual way to have a chance to
         // set request properties as proxy auth (EW).
         return openURL(url.openConnection());
     }
 
-    public static InputStream openURL(final URLConnection conn) throws IOException {
+    public static InputStream openURL(final URLConnection conn) throws IOException
+    {
         // Do it the manual way to have a chance to
         // set request properties as proxy auth (EW).
         setProxyAuth(conn);
-        return conn.getInputStream();
+        try
+        {
+            return conn.getInputStream();
+        }
+        catch (IOException e)
+        {
+            // Rather than just throwing the original exception, we wrap it
+            // because in some cases the original exception doesn't include
+            // the full URL (see FELIX-2912).
+            URL url = conn.getURL();
+            IOException newException = new IOException("Error accessing " + url);
+            newException.initCause(e);
+            throw newException;
+        }
     }
-
 }
\ No newline at end of file