You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2010/12/21 19:38:57 UTC
svn commit: r1051604 -
/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
Author: rickhall
Date: Tue Dec 21 18:38:56 2010
New Revision: 1051604
URL: http://svn.apache.org/viewvc?rev=1051604&view=rev
Log:
Close HttpURLConnections to workaround a bug on android. (FELIX-2728)
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java?rev=1051604&r1=1051603&r2=1051604&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java Tue Dec 21 18:38:56 2010
@@ -21,6 +21,7 @@ package org.apache.felix.framework.cache
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
@@ -143,31 +144,46 @@ class JarRevision extends BundleRevision
if (!byReference)
{
- if (is == null)
+ URLConnection conn = null;
+ try
{
- // Do it the manual way to have a chance to
- // set request properties such as proxy auth.
- URL url = BundleCache.getSecureAction().createURL(null, getLocation(), null);
- URLConnection conn = url.openConnection();
-
- // Support for http proxy authentication.
- String auth = BundleCache.getSecureAction()
- .getSystemProperty("http.proxyAuth", null);
- if ((auth != null) && (auth.length() > 0))
+ if (is == null)
{
- if ("http".equals(url.getProtocol()) ||
- "https".equals(url.getProtocol()))
+ // Do it the manual way to have a chance to
+ // set request properties such as proxy auth.
+ URL url = BundleCache.getSecureAction().createURL(
+ null, getLocation(), null);
+ conn = url.openConnection();
+
+ // Support for http proxy authentication.
+ String auth = BundleCache.getSecureAction()
+ .getSystemProperty("http.proxyAuth", null);
+ if ((auth != null) && (auth.length() > 0))
{
- String base64 = Util.base64Encode(auth);
- conn.setRequestProperty(
- "Proxy-Authorization", "Basic " + base64);
+ if ("http".equals(url.getProtocol()) ||
+ "https".equals(url.getProtocol()))
+ {
+ String base64 = Util.base64Encode(auth);
+ conn.setRequestProperty(
+ "Proxy-Authorization", "Basic " + base64);
+ }
}
+ is = BundleCache.getSecureAction()
+ .getURLConnectionInputStream(conn);
}
- is = BundleCache.getSecureAction().getURLConnectionInputStream(conn);
- }
- // Save the bundle jar file.
- BundleCache.copyStreamToFile(is, m_bundleFile);
+ // Save the bundle jar file.
+ BundleCache.copyStreamToFile(is, m_bundleFile);
+ }
+ finally
+ {
+ // This is a hack to fix an issue on Android, where
+ // HttpURLConnections are not properly closed. (FELIX-2728)
+ if ((conn != null) && (conn instanceof HttpURLConnection))
+ {
+ ((HttpURLConnection) conn).disconnect();
+ }
+ }
}
}
}