From 75ae63ca12c91e65a098331c9ffe8ba1e981a6f7 Mon Sep 17 00:00:00 2001 From: Martin Entlicher Date: Mon, 29 Nov 2021 16:38:02 +0100 Subject: [PATCH] Check for nativeImagePath property. --- .../debugging/attach/NbAttachRequestHandler.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/attach/NbAttachRequestHandler.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/attach/NbAttachRequestHandler.java index 418ddad513b1..f2cb8e0cfe13 100644 --- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/attach/NbAttachRequestHandler.java +++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/attach/NbAttachRequestHandler.java @@ -50,6 +50,7 @@ import org.netbeans.modules.java.lsp.server.protocol.NbCodeLanguageClient; import org.netbeans.modules.java.nativeimage.debugger.api.NIDebugRunner; import org.netbeans.modules.nativeimage.api.debug.NIDebugger; +import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; import org.openide.util.RequestProcessor; @@ -82,6 +83,7 @@ public CompletableFuture attach(Map attachArguments, Debug } } + @NbBundle.Messages("MSG_UnknownNIPath=Unknown native image path. Please set `nativeImagePath`.") private CompletableFuture attachToNative(Map attachArguments, DebugAdapterContext context) { CompletableFuture resultFuture = new CompletableFuture<>(); String processAndExe = (String) attachArguments.get("processId"); // NOI18N @@ -92,11 +94,17 @@ private CompletableFuture attachToNative(Map attachArgumen try { if (index > 0) { processId = Long.parseLong(processAndExe.substring(0, index)); - if (nativeImagePath.isEmpty()) { + if (nativeImagePath == null || nativeImagePath.isEmpty()) { nativeImagePath = processAndExe.substring(index + 1); } } else { processId = Long.parseLong(processAndExe); + if (nativeImagePath == null) { + ErrorUtilities.completeExceptionally(resultFuture, + Bundle.MSG_UnknownNIPath(), + ResponseErrorCode.serverErrorStart); + return resultFuture; + } } String executable = nativeImagePath; RP.post(() -> attachNativeDebug(new File(executable), processId, miDebugger, context, resultFuture));