发布

  • [OPIK-6982] Fix ClosingTraceThreadSubscriber NPE on null workspace timeout (#7147)

    frostbyte_neo 发布于 2026-06-18 09:27:43 +00:00

    • [OPIK-6982] Fix ClosingTraceThreadSubscriber NPE on null workspace timeout

    The closing trace-thread subscriber failed with
    "NullPointerException: The mapper [...] returned a null value." for any
    workspace that has a configuration record where timeoutToMarkThreadAsInactive
    is null (e.g. only truncationOnTables is set).

    getWorkspaceTimeout used .map(WorkspaceConfiguration::timeoutToMarkThreadAsInactive)
    followed by .switchIfEmpty(default). switchIfEmpty only fires on empty
    completion, not when the config is present but the timeout field is null —
    so map() emitted null, which Reactor rejects, and that workspace's threads
    never closed.

    Switch to .mapNotNull(...).defaultIfEmpty(default) so a null timeout drops
    to empty and falls back to the default, covering both "no config" and
    "config with null timeout".

    Adds a regression test reproducing the null-timeout workspace config.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • [OPIK-6982] Bound regression test await with atMost so it fails fast

    Address review feedback (Baz): the Awaitility chain in the new test was
    unbounded and could hang indefinitely if the closing job never ran. Add
    .atMost(30, TimeUnit.SECONDS), matching the backend test convention.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • [OPIK-6982] Derive closing-job test waits from configured timeout

    Address review nit (JetoPistola): the closure-wait delays were hardcoded
    literals coupled to traceThreadConfig.timeoutToMarkThreadAsInactive in
    config-test.yml, so all three tests would silently drift if that default
    changed.

    Inject the @Config-bound TraceThreadConfig and derive the waits:

    • default-timeout cases wait defaultThreadTimeout + 500ms buffer
    • custom-timeout case derives its waits from the local customTimeout
      Also bound the remaining await() chains with .atMost(30s) so they fail fast.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • [OPIK-6982] Address review nits in closing-job test
    • Use UUID v7 for thread IDs (matches production) via a TimeBasedEpochGenerator.
    • Replace Mono.delay(...).block() sleeps with TestUtils.waitForMillis(...).
    • Bound every await() with an aggressive .atMost(AWAIT_TIMEOUT_SECONDS=10s)
      so tests fail fast (Awaitility already defaults to 10s; making it explicit
      and uniform, including the previously unbounded reopen-test awaits).

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com


    Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com

    下载附件