From df4696b24d0467b7b65e9f9886c25f4d2a614539 Mon Sep 17 00:00:00 2001 From: Rod Cheater Date: Thu, 24 Oct 2024 14:28:05 +1030 Subject: [PATCH] Undertow: ignore missing servlet class in web.xml Avoids writing a null bean name to the bean archive, which causes a later build failure. Fixes #43825 --- .../undertow/deployment/UndertowBuildStep.java | 12 ++++++++---- .../undertow/deployment/WebXmlParsingBuildStep.java | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java index db3fba29da4b8..46cd9632e00f0 100644 --- a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java +++ b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java @@ -430,10 +430,14 @@ public ServletDeploymentManagerBuildItem build(List servlets, //add servlets if (webMetaData.getServlets() != null) { for (ServletMetaData servlet : webMetaData.getServlets()) { + String servletClass = servlet.getServletClass(); + if (servletClass == null) { + continue; + } reflectiveClasses.accept( - ReflectiveClassBuildItem.builder(servlet.getServletClass()).build()); + ReflectiveClassBuildItem.builder(servletClass).build()); RuntimeValue sref = recorder.registerServlet(deployment, servlet.getServletName(), - context.classProxy(servlet.getServletClass()), + context.classProxy(servletClass), servlet.isAsyncSupported(), servlet.getLoadOnStartupInt(), bc.getValue(), @@ -447,7 +451,7 @@ public ServletDeploymentManagerBuildItem build(List servlets, if (webMetaData.getAnnotations() != null) { for (AnnotationMetaData amd : webMetaData.getAnnotations()) { final ServletSecurityMetaData ssmd = amd.getServletSecurity(); - if (ssmd != null && amd.getClassName().equals(servlet.getServletClass())) { + if (ssmd != null && amd.getClassName().equals(servletClass)) { // Process the @ServletSecurity into metadata ServletSecurityInfo securityInfo = new ServletSecurityInfo(); securityInfo.setEmptyRoleSemantic( @@ -471,7 +475,7 @@ public ServletDeploymentManagerBuildItem build(List servlets, } final MultipartConfigMetaData mcmd = amd.getMultipartConfig(); - if (mcmd != null && amd.getClassName().equals(servlet.getServletClass())) { + if (mcmd != null && amd.getClassName().equals(servletClass)) { servlet.setMultipartConfig(mcmd); } } diff --git a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/WebXmlParsingBuildStep.java b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/WebXmlParsingBuildStep.java index b7d986ceb5fe5..05c76d6874001 100644 --- a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/WebXmlParsingBuildStep.java +++ b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/WebXmlParsingBuildStep.java @@ -79,7 +79,10 @@ WebMetadataBuildItem createWebMetadata(ApplicationArchivesBuildItem applicationA } if (metadata.getServlets() != null) { for (ServletMetaData i : metadata.getServlets()) { - additionalBeans.add(i.getServletClass()); + String servletClass = i.getServletClass(); + if (servletClass != null) { + additionalBeans.add(servletClass); + } } } if (metadata.getFilters() != null) {