This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 74628974a8879a2941d90e89050d2d1b77000a14 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue May 17 11:11:38 2022 +0100 Improve handling of errors associated with --enable-preview --- .../el/TestImportHandlerStandardPackages.java | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/test/jakarta/el/TestImportHandlerStandardPackages.java b/test/jakarta/el/TestImportHandlerStandardPackages.java index a20b19aa72..2f0ad4daf8 100644 --- a/test/jakarta/el/TestImportHandlerStandardPackages.java +++ b/test/jakarta/el/TestImportHandlerStandardPackages.java @@ -72,9 +72,13 @@ public class TestImportHandlerStandardPackages { try { return Class.forName("java.lang." + c); // Get the class object } catch (ClassNotFoundException e) { - throw new RuntimeException(); + throw new RuntimeException(c); + } catch (Throwable t) { + swallowEnablePreview(c, t); + return null; } }) + .filter(c -> null != c) .filter(c -> Modifier.isPublic(c.getModifiers())) // Exclude non-public classes .map(c -> c.getName().substring(10)) // Back to the class name .map(c -> c.replace('$', '.')) @@ -158,4 +162,25 @@ public class TestImportHandlerStandardPackages { Stream<String> result = (Stream<String>) clazzModuleReader.getMethod("list").invoke(mr); return result; } + + + /* + * This is a bit of a hack but there isn't a specific exception that can be + * caught. + */ + private void swallowEnablePreview(String className, Throwable t) { + while (t != null) { + if (t.getMessage() != null && t.getMessage().contains("--enable-preview")) { + return; + } + + Throwable cause = t.getCause(); + if (t == cause) { + break; + } + t = cause; + } + + throw new RuntimeException(className, t); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org