From 9a557efd21b0cef47fefcc5f2d2b2f782a1af12d Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 14 Aug 2008 08:53:30 +0000 Subject: TUSCANY-2539 Change extensibility module to use a URL connection and turn caching off by default so that jar file handle is not held open. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@685821 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/extensibility/ServiceDiscovery.java | 8 ++++++++ .../apache/tuscany/sca/extension/helper/utils/ResourceHelper.java | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'branches') diff --git a/branches/sca-java-1.3.1/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java b/branches/sca-java-1.3.1/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java index 45a4494f24..3e702ea5db 100644 --- a/branches/sca-java-1.3.1/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java +++ b/branches/sca-java-1.3.1/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; +import java.net.URLConnection; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; @@ -263,6 +264,13 @@ public class ServiceDiscovery { try { is = AccessController.doPrivileged(new PrivilegedExceptionAction() { public InputStream run() throws IOException { + URLConnection connection = url.openConnection(); + // TUSCANY-2539 + // Don't cache connections by default to stop Tuscany locking contribution jar files + // done here as this is one of the first places we open a stream and the only way to + // set the default is to set it on an instance of URLConnection + connection.setDefaultUseCaches(false); + connection.setUseCaches(false); return url.openStream(); } }); diff --git a/branches/sca-java-1.3.1/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/utils/ResourceHelper.java b/branches/sca-java-1.3.1/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/utils/ResourceHelper.java index efa84c6816..4e7965ce60 100644 --- a/branches/sca-java-1.3.1/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/utils/ResourceHelper.java +++ b/branches/sca-java-1.3.1/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/utils/ResourceHelper.java @@ -24,6 +24,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; +import java.net.URLConnection; /** * TODO: Shouldn't this be using the contribution service? @@ -36,7 +37,9 @@ public class ResourceHelper { InputStream is; try { - is = scriptSrcUrl.openStream(); + URLConnection connection = scriptSrcUrl.openConnection(); + connection.setUseCaches(false); + is = connection.getInputStream(); } catch (IOException e) { throw new RuntimeException(e); } -- cgit v1.2.3