Class ExportReporterLifecycle

java.lang.Object
ai.attackframework.tools.burp.sinks.ExportReporterLifecycle

public final class ExportReporterLifecycle extends Object
Coordinates intentional shutdown and reset of long-lived export reporters.

This helper centralizes lifecycle transitions so UI stop actions, test teardown, and other reset paths do not need to duplicate per-reporter cleanup logic. Safe to call multiple times. Not all export paths maintain a scheduler, so this class stops only the reporters that own recurring background work or session-scoped reporter state.

  • Method Details

    • stopBackgroundReporters

      public static void stopBackgroundReporters()
      Stops recurring background reporters and clears their in-memory session state.

      Safe to call from any thread. Callers should set RuntimeConfig.setExportRunning(boolean) to false before invoking this method so in-flight work exits cooperatively.

    • stopAndClearPendingExportWork

      public static void stopAndClearPendingExportWork()
      Stops recurring reporters and clears queued export work that would otherwise keep retrying.

      Use when the UI transitions to a stopped state, including failed Start attempts, so the runtime matches what the Start/Stop controls show.

    • releaseRunResourcesAsync

      public static void releaseRunResourcesAsync()
      Releases run-scoped resources off-thread so the user-Stop click path stays responsive.

      Closes the cached OpenSearch transport and classic HTTP client pools. Apache HC5 pool shutdown can briefly block while pending connections drain, so the call runs on a short-lived daemon thread rather than the EDT or the start-abort worker.

      Intentionally NOT invoked from auto-abort paths: a failed Start did not establish a running export, and synchronously closing pools mid-abort can starve the EDT during the abort acknowledgement. The unload path performs the same closure synchronously via OpenSearchConnector.closeAll().

    • awaitStopReclaim

      public static void awaitStopReclaim(long timeoutMillis)
      Awaits completion of the most recent releaseRunResourcesAsync() worker, if any.

      Intended for test teardown so a Stop-triggered async OpenSearchConnector.closeAll() cannot race with a subsequent integration test that fetches a cached client. Returns once the thread terminates or the wait expires; thread-interruption is preserved.

      Parameters:
      timeoutMillis - maximum time to wait, in milliseconds; 0 waits indefinitely
    • stopAndClearSessionState

      public static void stopAndClearSessionState()
      Stops recurring reporters and clears process-local exporter session state.

      Used by extension unload and test teardown so reloads start from a clean in-memory baseline.

    • resetForTests

      public static void resetForTests()
      Resets reporter-related process state for test teardown.

      In addition to stopping background reporters, this clears session-only credential state, cached Burp metadata, the Montoya API provider, and the export-running flag so subsequent tests start from a clean process-local baseline.