From ff96d94da2ed2ac13276a2a94e796fdc11cab89d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ko=C5=BEusznik?= <jan@kozusznik.cz> Date: Wed, 13 Jun 2018 18:12:05 +0200 Subject: [PATCH] fix: NPE during click into empty workspace, not existent directory --- .../haas_spim_benchmark/commands/ManageSPIMBenchmark.java | 5 ++++- .../fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/commands/ManageSPIMBenchmark.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/commands/ManageSPIMBenchmark.java index aaee9aab..f6e05832 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/commands/ManageSPIMBenchmark.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/commands/ManageSPIMBenchmark.java @@ -4,6 +4,7 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -61,7 +62,9 @@ public class ManageSPIMBenchmark implements Command { public void run() { try { Path workingDirPath = Paths.get(workingDirectory.getPath()); - + if (!Files.isDirectory(workingDirPath)) { + Files.createDirectories(workingDirPath); + } FileLock fl = new FileLock(workingDirPath.resolve(LOCK_FILE_NAME)); if(!fl.tryLock()) { uiService.showDialog("Working directory is already used by someone else", MessageType.ERROR_MESSAGE); diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java index bc58039c..4678ed75 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java @@ -143,7 +143,7 @@ public class BenchmarkSPIMControl extends BorderPane implements CloseableControl job -> JavaFXRoutines.notNullValue(job, j -> !j.isUseDemoData() && !EnumSet.of(JobState.Running, JobState.Disposed).contains(j.getState())), - job -> job.getUploadProgress().isWorking()); + job -> job != null && job.getUploadProgress().isWorking()); menu.addItem("Download result", job -> executeWSCallAsync("Downloading data", p -> job.getValue().startDownload()), job -> executeWSCallAsync("Stop downloading data", p -> job.getValue().stopDownload()), @@ -151,7 +151,7 @@ public class BenchmarkSPIMControl extends BorderPane implements CloseableControl .notNullValue(job, j -> EnumSet.of(JobState.Failed, JobState.Finished, JobState.Canceled) .contains(j.getState()) && j.canBeDownloaded()), - job -> job.getDownloadProgress().isWorking()); + job -> job != null && job.getDownloadProgress().isWorking()); menu.addItem("Download statistics", job -> executeWSCallAsync("Downloading data", p -> job.getValue().downloadStatistics(p)), -- GitLab