From ec7bd83e1afb1f08ff8f809331526c5186f61b62 Mon Sep 17 00:00:00 2001 From: Michael Dick Date: Wed, 20 Feb 2008 15:02:30 +0000 Subject: [PATCH] OPENJPA-518 Committing code changes suggested by Adam Toback git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@629492 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/openjpa/lib/util/Services.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Services.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Services.java index e50280fd5..e13b09fea 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Services.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Services.java @@ -23,6 +23,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.util.ArrayList; import java.util.Arrays; @@ -111,11 +112,16 @@ public class Services { * ignored. */ private static void addResources(URL url, Set set) throws IOException { - InputStream in = url.openConnection().getInputStream(); + InputStream in = null; + BufferedReader reader = null; + URLConnection urlCon = null; try { - BufferedReader reader = new BufferedReader(new InputStreamReader( - in)); + urlCon = url.openConnection(); + urlCon.setUseCaches(false); + in = urlCon.getInputStream(); + reader = new BufferedReader(new InputStreamReader(in)); + String line; while ((line = reader.readLine()) != null) { if (line.trim().startsWith("#") @@ -133,6 +139,11 @@ public class Services { } } } finally { + try { + reader.close(); + } catch (IOException ioe) { + // silently consume exception + } try { in.close(); } catch (IOException ioe) {