Changeset 16052 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-03-07T10:03:06+01:00 (5 years ago)
Author:
simon04
Message:

fix #18878 - JOSM leaves behind josm_exec_ temp files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r16003 r16052  
    922922            Logging.debug(String.join(" ", command));
    923923        }
    924         Path out = Files.createTempFile("josm_exec_", ".txt");
    925         Process p = new ProcessBuilder(command).redirectErrorStream(true).redirectOutput(out.toFile()).start();
    926         if (!p.waitFor(timeout, unit) || p.exitValue() != 0) {
    927             throw new ExecutionException(command.toString(), null);
    928         }
    929         String msg = String.join("\n", Files.readAllLines(out)).trim();
     924        Path out = Files.createTempFile("josm_exec_" + command.get(0) + "_", ".txt");
    930925        try {
    931             Files.delete(out);
    932         } catch (IOException e) {
    933             Logging.warn(e);
    934         }
    935         return msg;
     926            Process p = new ProcessBuilder(command).redirectErrorStream(true).redirectOutput(out.toFile()).start();
     927            if (!p.waitFor(timeout, unit) || p.exitValue() != 0) {
     928                throw new ExecutionException(command.toString(), null);
     929            }
     930            return String.join("\n", Files.readAllLines(out)).trim();
     931        } finally {
     932            try {
     933                Files.delete(out);
     934            } catch (IOException e) {
     935                Logging.warn(e);
     936            }
     937        }
    936938    }
    937939
Note: See TracChangeset for help on using the changeset viewer.