Author: jacopoc
Date: Sat Jul 31 10:13:49 2010
New Revision: 981028

URL: http://svn.apache.org/viewvc?rev=981028&view=rev
Log:
Always close the stream of the xml file after the parsing is done: this fixes a 
bug where the file was not deleted when it was successfully imported at the 
second or third attempt.


Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java

Modified: 
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java?rev=981028&r1=981027&r2=981028&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java 
(original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java 
Sat Jul 31 10:13:49 2010
@@ -218,7 +218,19 @@ public class EntitySaxReader implements 
             return 0;
         }
         Debug.logImportant("Beginning import from URL: " + 
location.toExternalForm(), module);
-        return this.parse(location.openStream(), location.toString());
+        InputStream is = null;
+        long numberRead = 0;
+        try {
+            is = location.openStream();
+            numberRead = this.parse(is, location.toString());
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch(Exception e) {}
+            }
+        }
+        return numberRead;
     }
 
     public long parse(InputStream is, String docDescription) throws 
SAXException, java.io.IOException {


Reply via email to