This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/tomcat-maven-plugin.git


The following commit(s) were added to refs/heads/trunk by this push:
     new b6eeb3f  Check response body for manager errors
b6eeb3f is described below

commit b6eeb3fe1f04c0f259e32b3b7fc3a2a9cfc1eb82
Author: remm <[email protected]>
AuthorDate: Thu Feb 5 23:58:58 2026 +0100

    Check response body for manager errors
    
    Based on PR#27 submitted by Laurent Perez.
    Luckily all languages start non error status messages with "OK -", so
    this should be a good way to sort things out.
---
 .../tomcat/maven/plugin/tomcat/AbstractTomcatMojo.java  | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git 
a/tomcat-main-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat/AbstractTomcatMojo.java
 
b/tomcat-main-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat/AbstractTomcatMojo.java
index 968fb20..43ac7fb 100644
--- 
a/tomcat-main-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat/AbstractTomcatMojo.java
+++ 
b/tomcat-main-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat/AbstractTomcatMojo.java
@@ -68,15 +68,16 @@ public abstract class AbstractTomcatMojo
     {
         int statusCode = tomcatResponse.getStatusCode();
 
-        if ( statusCode >= 400 )
-        {
-            getLog().error( messagesProvider.getMessage( 
"tomcatHttpStatusError", statusCode,
-                                                         
tomcatResponse.getReasonPhrase() ) );
-
+        if (statusCode >= 400) {
+            getLog().error(
+                    messagesProvider.getMessage("tomcatHttpStatusError", 
statusCode, tomcatResponse.getReasonPhrase()));
+            throw new MojoExecutionException(
+                    messagesProvider.getMessage("tomcatHttpStatusError", 
statusCode, tomcatResponse.getReasonPhrase()) +
+                            ": " + tomcatResponse.getHttpResponseBody());
+        } else if (!tomcatResponse.getHttpResponseBody().startsWith("OK -")) {
+            getLog().error(messagesProvider.getMessage("tomcatHttpBodyError", 
tomcatResponse.getHttpResponseBody()));
             throw new MojoExecutionException(
-                messagesProvider.getMessage( "tomcatHttpStatusError", 
statusCode,
-                                             tomcatResponse.getReasonPhrase() 
) + ": "
-                    + tomcatResponse.getHttpResponseBody() );
+                    messagesProvider.getMessage("tomcatHttpBodyError", 
tomcatResponse.getHttpResponseBody()));
         }
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to