Class ResyncInspector
java.lang.Object
com.vaadin.observability.micrometer.ResyncInspector
Servlet-level glue shared by the resync/resend detection filters: it
recognizes UIDL requests, derives the per-UI key, and drives a
ResyncDetector against per-UI state kept in the HTTP session.
This class is deliberately framework-agnostic (servlet API only) so it can
back both the portable ResyncDetectionFilter and Spring-specific
filters. It holds no state of its own; the clientId history lives in
the session, keyed by UI id, so it is bounded by and cleaned up with the
session.
-
Constructor Summary
ConstructorsConstructorDescriptionResyncInspector(io.micrometer.core.instrument.MeterRegistry registry) Creates an inspector recording into the given registry. -
Method Summary
Modifier and TypeMethodDescriptionvoidClassifies a UIDL body against theclientIdlast seen for the same UI, records a counter for resend/resync, and stores the newclientIdback on the session.static booleanisUidl(jakarta.servlet.http.HttpServletRequest request) A UIDL request is a POST whose query string carriesv-r=uidl.static StringuiId(jakarta.servlet.http.HttpServletRequest request) Returns the UI id carried by the request, or"-"when absent.
-
Constructor Details
-
ResyncInspector
public ResyncInspector(io.micrometer.core.instrument.MeterRegistry registry) Creates an inspector recording into the given registry.- Parameters:
registry- the meter registry, notnull
-
-
Method Details
-
isUidl
public static boolean isUidl(jakarta.servlet.http.HttpServletRequest request) A UIDL request is a POST whose query string carriesv-r=uidl. Checking the query string (rather thangetParameter) avoids triggering body parsing on the original request.- Parameters:
request- the request to test- Returns:
trueif this is a UIDL POST
-
uiId
Returns the UI id carried by the request, or"-"when absent.- Parameters:
request- the request- Returns:
- the UI id, never
null
-
inspect
public void inspect(String body, jakarta.servlet.http.HttpSession session, String uiId, Object mutex) Classifies a UIDL body against theclientIdlast seen for the same UI, records a counter for resend/resync, and stores the newclientIdback on the session.The read-modify-write on the session attribute is guarded by
mutex: a resend can overlap the original request for the same UI (both reach the filter before Flow's per-session lock), and without the guard the two could clobber each other's storedclientId.- Parameters:
body- the UIDL request body (JSON); may benull/emptysession- the HTTP session holding per-UI state, ornulluiId- the UI id used to key the session attributemutex- the monitor to guard the read-modify-write on
-