add async support to all non-deprecated filters#294
Merged
Conversation
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>
There was a problem hiding this comment.
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 inmoskito-web’sweb-fragment.xml. - Added
setAsyncSupported(true)to Spring Boot (v1 and v2/3)FilterRegistrationBeanregistrations. - 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{ |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<async-supported>true</async-supported>to all filter declarations inmoskito-web/src/main/resources/META-INF/web-fragment.xml— the primary fix for apps that embed the JAR via web-fragment auto-registration@WebFilter(asyncSupported = true)to all active (non-deprecated) filter classes for annotation-scanning /@ServletComponentScandeploymentsregistrationBean.setAsyncSupported(true)to everyFilterRegistrationBeanin bothmoskito-springbootandmoskito-springboot2auto-configurationsDomainFilter,MethodFilter,RefererFilter,RequestURIFilter,UserAgentFilter) intentionally excludedWithout these changes, any filter in the chain that does not declare async support causes the servlet container to throw an
IllegalStateExceptionwhen a downstream endpoint (e.g. SSE/MCP) callsrequest.startAsync().Test plan
moskito-webJAR and verify an SSE or async endpoint passes through the filter chain withoutIllegalStateExceptionasyncSupported = true🤖 Generated with Claude Code