You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sk...@apache.org on 2005/10/17 11:09:26 UTC
svn commit: r325866 -
/jakarta/commons/proper/digester/trunk/src/java/org/apache/commons/digester/Digester.java
Author: skitching
Date: Mon Oct 17 02:09:19 2005
New Revision: 325866
URL: http://svn.apache.org/viewcvs?rev=325866&view=rev
Log:
Update to previous commit. There was another place in Digester class where
new InputSource(String) was being called, so the "safe" implementation of
that constructor has been factored out into a separate method. See bugzilla
#37034.
Modified:
jakarta/commons/proper/digester/trunk/src/java/org/apache/commons/digester/Digester.java
Modified: jakarta/commons/proper/digester/trunk/src/java/org/apache/commons/digester/Digester.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/digester/trunk/src/java/org/apache/commons/digester/Digester.java?rev=325866&r1=325865&r2=325866&view=diff
==============================================================================
--- jakarta/commons/proper/digester/trunk/src/java/org/apache/commons/digester/Digester.java (original)
+++ jakarta/commons/proper/digester/trunk/src/java/org/apache/commons/digester/Digester.java Mon Oct 17 02:09:19 2005
@@ -26,6 +26,7 @@
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.net.URLConnection;
+import java.net.MalformedURLException;
import java.util.EmptyStackException;
import java.util.HashMap;
import java.util.Iterator;
@@ -1517,21 +1518,7 @@
}
try {
- // Ideally we would just call
- // return (new InputSource(entityURL));
- // Unforunately it appears that when the entityURL
- // points to a file within a jar archive a caching mechanism
- // inside the InputSource implementation causes a file-handle
- // to the jar file to remain open. On Windows systems this then
- // causes the jar archive file to be locked on disk ("in use")
- // which makes it impossible to delete the jar file - and that
- // really stuffs up "undeploy" in webapps in particular.
- URLConnection urlConnection = new URL(entityURL).openConnection();
- urlConnection.setUseCaches(false);
- InputSource source = new InputSource(urlConnection.getInputStream());
- source.setSystemId(entityURL);
- return source;
-
+ return createInputSourceFromURL(entityURL);
} catch (Exception e) {
throw createSAXException(e);
}
@@ -1716,7 +1703,7 @@
public Object parse(String uri) throws IOException, SAXException {
configure();
- InputSource is = new InputSource(uri);
+ InputSource is = createInputSourceFromURL(uri);
getXMLReader().parse(is);
return (root);
@@ -1753,6 +1740,27 @@
}
+ /**
+ * Given a URL, return an InputSource that reads from that URL.
+ * <p>
+ * Ideally this function would not be needed and code could just use
+ * <code>new InputSource(entityURL)</code>.
+ * Unforunately it appears that when the entityURL points to a file
+ * within a jar archive a caching mechanism inside the InputSource
+ * implementation causes a file-handle to the jar file to remain open.
+ * On Windows systems this then causes the jar archive file to be
+ * locked on disk ("in use") which makes it impossible to delete the
+ * jar file - and that really stuffs up "undeploy" in webapps in
+ * particular.
+ */
+ private InputSource createInputSourceFromURL(String url)
+ throws MalformedURLException, IOException {
+ URLConnection urlConnection = new URL(url).openConnection();
+ urlConnection.setUseCaches(false);
+ InputSource source = new InputSource(urlConnection.getInputStream());
+ source.setSystemId(url);
+ return source;
+ }
// --------------------------------------------------------- Rule Methods
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org