From 410c2fd87899c34863095bfa07ce5b18c7ac38e7 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 6 Apr 2021 15:01:22 +0300 Subject: [PATCH] Avoid nasty NPE when trying to open Eclipse IDE --- .../src/main/java/io/quarkus/deployment/ide/Ide.java | 6 ++++++ .../http/deployment/devmode/console/OpenIdeHandler.java | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ide/Ide.java b/core/deployment/src/main/java/io/quarkus/deployment/ide/Ide.java index eaaa002bc6fa3..784e12616d049 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/ide/Ide.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/ide/Ide.java @@ -66,4 +66,10 @@ public void setMachineSpecificCommand(String machineSpecificCommand) { this.machineSpecificCommand = machineSpecificCommand; } + @Override + public String toString() { + return "Ide{" + + "defaultCommand='" + defaultCommand + '\'' + + '}'; + } } diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/OpenIdeHandler.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/OpenIdeHandler.java index 16a7190db07f2..2aade3ca6b8cd 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/OpenIdeHandler.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/OpenIdeHandler.java @@ -77,7 +77,13 @@ protected void launchInIDE(Ide ide, String arg, RoutingContext routingContext) { new Thread(new Runnable() { public void run() { try { - new ProcessBuilder(Arrays.asList(ide.getEffectiveCommand(), arg)).inheritIO().start().waitFor(10, + String effectiveCommand = ide.getEffectiveCommand(); + if (isNullOrEmpty(effectiveCommand)) { + log.debug("Unable to determine proper launch command for IDE: " + ide); + routingContext.response().setStatusCode(500).end(); + return; + } + new ProcessBuilder(Arrays.asList(effectiveCommand, arg)).inheritIO().start().waitFor(10, TimeUnit.SECONDS); routingContext.response().setStatusCode(200).end(); } catch (Exception e) {