Class ResyncInspector

java.lang.Object
com.vaadin.observability.micrometer.ResyncInspector

public final class ResyncInspector extends Object
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

    Constructors
    Constructor
    Description
    ResyncInspector(io.micrometer.core.instrument.MeterRegistry registry)
    Creates an inspector recording into the given registry.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    inspect(String body, jakarta.servlet.http.HttpSession session, String uiId, Object mutex)
    Classifies a UIDL body against the clientId last seen for the same UI, records a counter for resend/resync, and stores the new clientId back on the session.
    static boolean
    isUidl(jakarta.servlet.http.HttpServletRequest request)
    A UIDL request is a POST whose query string carries v-r=uidl.
    static String
    uiId(jakarta.servlet.http.HttpServletRequest request)
    Returns the UI id carried by the request, or "-" when absent.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResyncInspector

      public ResyncInspector(io.micrometer.core.instrument.MeterRegistry registry)
      Creates an inspector recording into the given registry.
      Parameters:
      registry - the meter registry, not null
  • Method Details

    • isUidl

      public static boolean isUidl(jakarta.servlet.http.HttpServletRequest request)
      A UIDL request is a POST whose query string carries v-r=uidl. Checking the query string (rather than getParameter) avoids triggering body parsing on the original request.
      Parameters:
      request - the request to test
      Returns:
      true if this is a UIDL POST
    • uiId

      public static String uiId(jakarta.servlet.http.HttpServletRequest request)
      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 the clientId last seen for the same UI, records a counter for resend/resync, and stores the new clientId back 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 stored clientId.

      Parameters:
      body - the UIDL request body (JSON); may be null/empty
      session - the HTTP session holding per-UI state, or null
      uiId - the UI id used to key the session attribute
      mutex - the monitor to guard the read-modify-write on