From 1674f95bd186dd10424a5940ea4c1adfd092e4fb Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 11 Nov 2022 18:42:11 -0800 Subject: [PATCH] fix: do not fail on a bad file name in stack trace (#1120) --- .../microsoft/playwright/impl/StackTraceCollector.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/StackTraceCollector.java b/playwright/src/main/java/com/microsoft/playwright/impl/StackTraceCollector.java index f137b8ac..af6e26b4 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/StackTraceCollector.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/StackTraceCollector.java @@ -69,7 +69,13 @@ class StackTraceCollector { if (file == null) { return ""; } - return resolveSourcePath(Paths.get(pkg).resolve(file)); + try { + // The file name can contain an arbitrary string which may cause Path implementation + // to throw. See https://github.com/microsoft/playwright-java/issues/1115 + return resolveSourcePath(Paths.get(pkg).resolve(file)); + } catch (RuntimeException e) { + return ""; + } } private String resolveSourcePath(Path relativePath) {