Kaydet (Commit) 03c37cee authored tarafından jan iversen's avatar jan iversen Kaydeden (comit) Markus Mohrhard

CID#1326472, CID#1326473, CID#1326474 use try/finalize

Coverity requires that closeable objects (use of new) call .close(),

git commit 5a29db7a
implemented a series of .close etc calls, update to
use a single try{}finalize{} instead.

Change-Id: Iadc9de13d6a0af4b0aaca2dfdd0e2d0940a5223d
Reviewed-on: https://gerrit.libreoffice.org/19807Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst bc7a490a
......@@ -375,6 +375,9 @@ public class XMergeBridge {
XInputStreamToInputStreamAdapter xis =new XInputStreamToInputStreamAdapter(xml);
XOutputStreamToOutputStreamAdapter newxos =new XOutputStreamToOutputStreamAdapter(device);
/* make sure newxos and xis get closed */
try{
try{
ConverterInfoReader cir = new ConverterInfoReader(jarName,false);
ciEnum =cir.getConverterInfoEnumeration();
......@@ -417,6 +420,7 @@ public class XMergeBridge {
newxos.flush();
newxos.close();
newxos = null;
int i=1;
while (docEnum.hasNext() && sURL.startsWith("file:")) {
......@@ -437,7 +441,6 @@ public class XMergeBridge {
docOut.write(fos);
fos.flush();
fos.close();
fos = null;
i++;
}
......@@ -447,12 +450,6 @@ public class XMergeBridge {
ConverterInfoMgr.removeByJar(jarName);
}
catch (Exception ex1) {
/* Satisfy coverity */
newxos.flush();
newxos.close();
newxos = null;
xis.close();
xis = null;
IOException ex2 = new IOException();
ex2.initCause(ex1);
throw ex2;
......@@ -480,6 +477,7 @@ public class XMergeBridge {
docIn.write(newxos,false);
}
newxos.close();
newxos = null;
}
ConverterInfoMgr.removeByJar(jarName);
}
......@@ -487,24 +485,20 @@ public class XMergeBridge {
System.out.println("\nERROR : Stack Overflow. \n Increase of the JRE by adding the following line to the end of the javarc file \n \"-Xss1m\"\n");
}
catch (Exception ex1) {
/* Satisfy coverity */
newxos.flush();
newxos.close();
newxos = null;
xis.close();
xis = null;
IOException ex2 = new IOException();
ex2.initCause(ex1);
throw ex2;
}
}
/* Satisfy coverity */
}
finally{
if (newxos != null){
newxos.flush();
newxos.close();
newxos = null;
}
xis.close();
xis = null;
}
}
private String getPath(URI uri){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment