Class ResyncDetectionFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
SpringResyncDetectionFilter instead.
Registering it in a plain servlet app. There is no auto-configuration
outside Spring, so register the filter yourself against every request. It
should run early (before anything else consumes the request body). For
example, in a ServletContextListener or
ServletContainerInitializer:
FilterRegistration.Dynamic reg = servletContext.addFilter(
"vaadinResyncDetection", new ResyncDetectionFilter(meterRegistry));
// isMatchAfter=false so it precedes already-registered filters
reg.addMappingForUrlPatterns(null, false, "/*");
or the equivalent <filter>/<filter-mapping> in
web.xml. The MeterRegistry is whichever instance the
application records into.
Flow recovers from lost responses entirely inside UidlRequestHandler
by catching ClientResentPayloadException (replay the cached response)
and ResynchronizationRequiredException (rebuild the UI state);
neither surfaces to any Flow listener SPI the kit uses. This filter
reconstructs the same signal by buffering the UIDL body (via
CachedBodyHttpServletRequest so Flow can still read it) and handing
it to a ResyncInspector.
Because it has no Spring APIs available it buffers the body eagerly; the Spring variant instead captures the bytes lazily as Flow reads them and only counts requests Flow actually consumed. Instrumentation never fails the request: any error while inspecting is swallowed.
-
Constructor Summary
ConstructorsConstructorDescriptionResyncDetectionFilter(io.micrometer.core.instrument.MeterRegistry registry) Creates the filter recording into the given registry. -
Method Summary
Modifier and TypeMethodDescriptionvoiddoFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.Filter
destroy, init
-
Constructor Details
-
ResyncDetectionFilter
public ResyncDetectionFilter(io.micrometer.core.instrument.MeterRegistry registry) Creates the filter recording into the given registry.- Parameters:
registry- the meter registry, notnull
-
-
Method Details
-
doFilter
public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException - Specified by:
doFilterin interfacejakarta.servlet.Filter- Throws:
IOExceptionjakarta.servlet.ServletException
-