Am 02.05.26 um 09:29 schrieb Rainer Jung:
Hi Dimitris,

some of the new tests fail for me consistently. For details please see below.

Should be fixed by bea9b2a46ac41a459d03c5e2a9af0a536ca8c287. I took the code from StandardHost and adjusted it. Other places use "instanceof" instead of comparing class names. I hope the fix is OK for you.

Best regards,

Rainer


Am 08.04.26 um 14:20 schrieb [email protected]:
This is an automated email from the ASF dual-hosted git repository.

dsoumis pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 48343a64f24258be7e273d49849ee866463be67c
Author: Dimitris Soumis <[email protected]>
AuthorDate: Wed Apr 8 14:52:53 2026 +0300

     Add more tests and minor fixes for FilterValve, ProxyErrorReportValve and SemaphoreValve
---
  .../apache/catalina/valves/TestFilterValve.java    |  99 ++++----
  .../catalina/valves/TestProxyErrorReportValve.java | 121 +++++-----
  .../apache/catalina/valves/TestSemaphoreValve.java | 254 +++++++++++ +++++++---
  3 files changed, 333 insertions(+), 141 deletions(-)


diff --git a/test/org/apache/catalina/valves/ TestProxyErrorReportValve.java b/test/org/apache/catalina/valves/ TestProxyErrorReportValve.java
index 98a92fe84f..8829fa2d63 100644
--- a/test/org/apache/catalina/valves/TestProxyErrorReportValve.java
+++ b/test/org/apache/catalina/valves/TestProxyErrorReportValve.java
...

@@ -54,28 +50,49 @@ public class TestProxyErrorReportValve extends TomcatBaseTest {                   HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Server broke"));
          ctx.addServletMappingDecoded("/", "error");
-        // Register an error page that the valve will redirect to
+        // Register an error page at the Host's error report valve level
+        // so findErrorPage() returns a URL for the redirect
+        Tomcat.addServlet(ctx, "errorPage", new ErrorPageServlet());
+        ctx.addServletMappingDecoded("/error-page", "errorPage");
+
+        tomcat.start();
+
+        ProxyErrorReportValve valve = (ProxyErrorReportValve) host.getPipeline().getFirst();

I get an exception here:

class org.apache.catalina.valves.AccessLogValve cannot be cast to class org.apache.catalina.valves.ProxyErrorReportValve (org.apache.catalina.valves.AccessLogValve and org.apache.catalina.valves.ProxyErrorReportValve are in unnamed module of loader 'app') java.lang.ClassCastException: class org.apache.catalina.valves.AccessLogValve cannot be cast to class org.apache.catalina.valves.ProxyErrorReportValve (org.apache.catalina.valves.AccessLogValve and org.apache.catalina.valves.ProxyErrorReportValve are in unnamed module of loader 'app')         at org.apache.catalina.valves.TestProxyErrorReportValve.testRedirectMode(TestProxyErrorReportValve.java:60)         at java.base/ jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/ jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)         at java.base/ jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)


...

+    @Test
+    public void testProxyMode() throws Exception {
+        Tomcat tomcat = getTomcatInstance();
+        StandardHost host = (StandardHost) tomcat.getHost();
+        host.setErrorReportValveClass(PROXY_VALVE);
+
+        Context ctx = getProgrammaticRootContext();
+
+        Tomcat.addServlet(ctx, "error", new SendErrorServlet(
+                HttpServletResponse.SC_NOT_FOUND, "Not found"));
+        ctx.addServletMappingDecoded("/", "error");
+
          Tomcat.addServlet(ctx, "errorPage", new ErrorPageServlet());
          ctx.addServletMappingDecoded("/error-page", "errorPage");
-        ErrorPage errorPage = new ErrorPage();
- errorPage.setErrorCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-        errorPage.setLocation("/error-page");
-        ctx.addErrorPage(errorPage);
          tomcat.start();
+        ProxyErrorReportValve valve = (ProxyErrorReportValve) host.getPipeline().getFirst();

and here

class org.apache.catalina.valves.AccessLogValve cannot be cast to class org.apache.catalina.valves.ProxyErrorReportValve (org.apache.catalina.valves.AccessLogValve and org.apache.catalina.valves.ProxyErrorReportValve are in unnamed module of loader 'app') java.lang.ClassCastException: class org.apache.catalina.valves.AccessLogValve cannot be cast to class org.apache.catalina.valves.ProxyErrorReportValve (org.apache.catalina.valves.AccessLogValve and org.apache.catalina.valves.ProxyErrorReportValve are in unnamed module of loader 'app')         at org.apache.catalina.valves.TestProxyErrorReportValve.testProxyMode(TestProxyErrorReportValve.java:86)         at java.base/ jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/ jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)         at java.base/ jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Maybe this is due to running the tests here with test.accesslog=true? I turn the access log on during tests so that I can find out failure reasons more quickly.

Best regards,

Rainer

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

Reply via email to