Skip to content

add async support to all non-deprecated filters#294

Merged
dvayanu merged 3 commits into
developfrom
feature/async-filter-support
Jun 26, 2026
Merged

add async support to all non-deprecated filters#294
dvayanu merged 3 commits into
developfrom
feature/async-filter-support

Conversation

@dvayanu

@dvayanu dvayanu commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Added <async-supported>true</async-supported> to all filter declarations in moskito-web/src/main/resources/META-INF/web-fragment.xml — the primary fix for apps that embed the JAR via web-fragment auto-registration
  • Added @WebFilter(asyncSupported = true) to all active (non-deprecated) filter classes for annotation-scanning / @ServletComponentScan deployments
  • Added registrationBean.setAsyncSupported(true) to every FilterRegistrationBean in both moskito-springboot and moskito-springboot2 auto-configurations
  • Deprecated filters (DomainFilter, MethodFilter, RefererFilter, RequestURIFilter, UserAgentFilter) intentionally excluded

Without these changes, any filter in the chain that does not declare async support causes the servlet container to throw an IllegalStateException when a downstream endpoint (e.g. SSE/MCP) calls request.startAsync().

Test plan

  • Deploy an app using the moskito-web JAR and verify an SSE or async endpoint passes through the filter chain without IllegalStateException
  • Verify Spring Boot auto-configuration registers filters with asyncSupported = true
  • Confirm existing synchronous request monitoring still works correctly

🤖 Generated with Claude Code

Enables async servlet support across all active MoSKito filters so they
do not block async dispatch chains (e.g. SSE/MCP endpoints). Three
deployment paths are covered: web-fragment.xml (<async-supported>true),
@webfilter(asyncSupported=true) on each filter class, and
FilterRegistrationBean.setAsyncSupported(true) in the Spring Boot 1/2
auto-configurations. Deprecated filters are intentionally excluded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to ensure MoSKito’s servlet filters are async-capable so downstream async endpoints (e.g., SSE) can safely call request.startAsync() without the container throwing IllegalStateException.

Changes:

  • Added <async-supported>true</async-supported> to filter declarations in moskito-web’s web-fragment.xml.
  • Added setAsyncSupported(true) to Spring Boot (v1 and v2/3) FilterRegistrationBean registrations.
  • Added @WebFilter(asyncSupported = true) annotations to multiple filter classes.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
moskito-webui/src/main/java/net/anotheria/moskito/webui/MoskitoUIFilter.java Adds @WebFilter(asyncSupported = true) to the UI filter.
moskito-web/src/main/resources/META-INF/web-fragment.xml Marks the fragment-registered filters as async-supported.
moskito-web/src/main/java/net/anotheria/moskito/web/util/SessionThrottleFilter.java Adds @WebFilter(asyncSupported = true) to the throttle filter.
moskito-web/src/main/java/net/anotheria/moskito/web/filters/SourceTldFilter.java Adds @WebFilter(asyncSupported = true).
moskito-web/src/main/java/net/anotheria/moskito/web/filters/SourceIpSegmentFilter.java Adds @WebFilter(asyncSupported = true).
moskito-web/src/main/java/net/anotheria/moskito/web/filters/MoskitoCommandFilter.java Adds @WebFilter(asyncSupported = true).
moskito-web/src/main/java/net/anotheria/moskito/web/filters/JSTalkBackFilter.java Adds @WebFilter(asyncSupported = true).
moskito-web/src/main/java/net/anotheria/moskito/web/filters/JourneyStarterFilter.java Adds @WebFilter(asyncSupported = true).
moskito-web/src/main/java/net/anotheria/moskito/web/filters/JourneyFilter.java Adds @WebFilter(asyncSupported = true).
moskito-web/src/main/java/net/anotheria/moskito/web/filters/GenericMonitoringFilter.java Adds @WebFilter(asyncSupported = true).
moskito-web/src/main/java/net/anotheria/moskito/web/filters/DebugRequestFilter.java Adds @WebFilter(asyncSupported = true).
moskito-web/src/main/java/net/anotheria/moskito/web/filters/AsyncSourceTldFilter.java Adds @WebFilter(asyncSupported = true).
moskito-integration/moskito-springboot2/src/main/java/net/anotheria/moskito/integration/springboot/MoskitoAutoConfiguration.java Sets setAsyncSupported(true) on each registered filter bean.
moskito-integration/moskito-springboot/src/main/java/net/anotheria/moskito/integration/springboot/MoskitoAutoConfiguration.java Sets setAsyncSupported(true) on each registered filter bean (and touches JSTalkBackFilter registration).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +38 to 39
@WebFilter(asyncSupported = true)
public class MoskitoUIFilter extends MAFFilter{
Comment on lines +31 to 32
@WebFilter(asyncSupported = true)
public class SessionThrottleFilter implements Filter{
Comment on lines +20 to 21
@WebFilter(asyncSupported = true)
public class SourceTldFilter extends MoskitoFilter {
Comment on lines +16 to 17
@WebFilter(asyncSupported = true)
public class SourceIpSegmentFilter extends MoskitoFilter {
Comment on lines +19 to 20
@WebFilter(asyncSupported = true)
public class MoskitoCommandFilter implements Filter{
Comment on lines +37 to 38
@WebFilter(asyncSupported = true)
public class JourneyFilter implements Filter {
Comment on lines +42 to 43
@WebFilter(asyncSupported = true)
public class GenericMonitoringFilter implements Filter, IStatsProducer {
Comment on lines +25 to 26
@WebFilter(asyncSupported = true)
public class DebugRequestFilter implements Filter {
Comment on lines +27 to 28
@WebFilter(asyncSupported = true)
public class AsyncSourceTldFilter extends MoskitoFilter{
dvayanu and others added 2 commits June 27, 2026 00:21
JSTalkBackFilter.doFilter terminates the chain (it never calls
filterChain.doFilter), so registering it for "/*" would swallow all
requests. Map it to "/jstalkbackfilter/*" to match web-fragment.xml.

Note: the moskito-springboot (v1) module is disabled in the build
(superseded by moskito-springboot2), so this corrects dormant code.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…er-support

# Conflicts:
#	moskito-integration/moskito-springboot/src/main/java/net/anotheria/moskito/integration/springboot/MoskitoAutoConfiguration.java
@dvayanu dvayanu merged commit e76fda6 into develop Jun 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants