"Applied fix from trunk for revision: 1857099"
------------------------------------------------------------------------ r1857099 | jleroux | 2019-04-08 11:17:55 +0200 (lun. 08 avr. 2019) | 12 lignes Improved: Using try-with-resources with File IO Objects. (OFBIZ-9855) Uses try with resources for File IO objects like ObjectInputStream and other objects. File classes have the AutoCloseable interface. jleroux: this is only a part of the 2nd patch. The 1st patch will be committed soon too... All tests pass Thanks: Pradhan Yash Sharma ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release18.12@1857486 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -188,9 +188,10 @@ public class EntitySaxReader extends DefaultHandler {
|
||||
Debug.logWarning("content was null, doing nothing", module);
|
||||
return 0;
|
||||
}
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(content.getBytes("UTF-8"));
|
||||
|
||||
try (ByteArrayInputStream bis = new ByteArrayInputStream(content.getBytes("UTF-8"))) {
|
||||
return this.parse(bis, "Internal Content");
|
||||
}
|
||||
}
|
||||
|
||||
public long parse(URL location) throws SAXException, java.io.IOException {
|
||||
@@ -199,17 +200,9 @@ public class EntitySaxReader extends DefaultHandler {
|
||||
return 0;
|
||||
}
|
||||
Debug.logImportant("Beginning import from URL: " + location.toExternalForm(), module);
|
||||
InputStream is = null;
|
||||
long numberRead = 0;
|
||||
try {
|
||||
is = location.openStream();
|
||||
try (InputStream is = location.openStream()) {
|
||||
numberRead = this.parse(is, location.toString());
|
||||
} finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
return numberRead;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user