Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 14084 invoked from network); 21 Dec 2010 18:39:19 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Dec 2010 18:39:19 -0000 Received: (qmail 15126 invoked by uid 500); 21 Dec 2010 18:39:19 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 15073 invoked by uid 500); 21 Dec 2010 18:39:18 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 15061 invoked by uid 99); 21 Dec 2010 18:39:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Dec 2010 18:39:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Dec 2010 18:39:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 574FD23888FE; Tue, 21 Dec 2010 18:38:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1051604 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java Date: Tue, 21 Dec 2010 18:38:57 -0000 To: commits@felix.apache.org From: rickhall@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101221183857.574FD23888FE@eris.apache.org> 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(); + } + } } } }