Browse Source

SimulatorEngine: Fix ressource leak (log)

master
Joachim Klein 7 years ago
parent
commit
06becee4dc
  1. 7
      prism/src/simulator/SimulatorEngine.java

7
prism/src/simulator/SimulatorEngine.java

@ -1338,7 +1338,8 @@ public class SimulatorEngine extends PrismComponent
*/ */
public void exportPath(File file, boolean timeCumul, String colSep, ArrayList<Integer> vars) throws PrismException public void exportPath(File file, boolean timeCumul, String colSep, ArrayList<Integer> vars) throws PrismException
{ {
PrismLog log;
PrismLog log = null;
try {
if (path == null) if (path == null)
throw new PrismException("There is no path to export"); throw new PrismException("There is no path to export");
// create new file log or use main log // create new file log or use main log
@ -1355,6 +1356,10 @@ public class SimulatorEngine extends PrismComponent
((PathFull) path).exportToLog(log, timeCumul, colSep, vars); ((PathFull) path).exportToLog(log, timeCumul, colSep, vars);
if (file != null) if (file != null)
log.close(); log.close();
} finally {
if (file != null && log != null)
log.close();
}
} }
/** /**

Loading…
Cancel
Save