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

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 66df5fd7548aac7ea3e80a75cb1b2cd2a3bda708
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Nov 8 20:29:59 2023 +0000

    Look for wrapped InvalidParameterException and use 400 response if found
---
 java/org/apache/catalina/core/StandardWrapperValve.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/core/StandardWrapperValve.java 
b/java/org/apache/catalina/core/StandardWrapperValve.java
index 9f59f6001d..6fde983636 100644
--- a/java/org/apache/catalina/core/StandardWrapperValve.java
+++ b/java/org/apache/catalina/core/StandardWrapperValve.java
@@ -286,7 +286,11 @@ final class StandardWrapperValve extends ValveBase {
      * @param exception The exception that occurred (which possibly wraps a 
root cause exception
      */
     private void exception(Request request, Response response, Throwable 
exception) {
-        exception(request, response, exception, 
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+        if (exception.getCause() instanceof InvalidParameterException) {
+            exception(request, response, exception, 
((InvalidParameterException) exception.getCause()).getErrorCode());
+        } else {
+            exception(request, response, exception, 
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+        }
     }
 
     private void exception(Request request, Response response, Throwable 
exception, int errorCode) {


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to