From 8bdc01f374b07b944d0cb774e9c2370d740718b9 Mon Sep 17 00:00:00 2001 From: Jinbo Wang Date: Fri, 22 Nov 2019 11:16:43 +0800 Subject: [PATCH] Fix NPE when searching the source for the exception stack trace Signed-off-by: Jinbo Wang --- .../java/debug/core/adapter/AdapterUtils.java | 10 ++++++---- .../handler/LaunchWithoutDebuggingDelegate.java | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/AdapterUtils.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/AdapterUtils.java index 35d99092b..e1103a5a3 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/AdapterUtils.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/AdapterUtils.java @@ -68,10 +68,12 @@ public static boolean isWindows() { * @return the absolute file path */ public static String sourceLookup(String[] sourcePaths, String sourceName) { - for (String path : sourcePaths) { - Path fullpath = Paths.get(path, sourceName); - if (Files.isRegularFile(fullpath)) { - return fullpath.toString(); + if (sourcePaths != null) { + for (String path : sourcePaths) { + Path fullpath = Paths.get(path, sourceName); + if (Files.isRegularFile(fullpath)) { + return fullpath.toString(); + } } } return null; diff --git a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchWithoutDebuggingDelegate.java b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchWithoutDebuggingDelegate.java index 804ee58ca..c993dc5f1 100644 --- a/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchWithoutDebuggingDelegate.java +++ b/com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchWithoutDebuggingDelegate.java @@ -137,6 +137,6 @@ public CompletableFuture launchInTerminal(LaunchArguments launchArgume @Override public void preLaunch(LaunchArguments launchArguments, IDebugAdapterContext context) { - // TODO Auto-generated method stub + context.setSourcePaths(launchArguments.sourcePaths); } }