Apache Software Foundation / SeaTunnel
Merged upstreamTestingMerged Oct 3, 2026

Make file rediscovery testing deterministic

Introduced an injectable millisecond clock for file-reader timing and used it to exercise cursor closure, glob rediscovery, and resumed line delivery in exact poll steps.

apache/seatunnel · #12472

Cross-platform CI reliability

SeaTunnel's edge file-reader test now drives idle-cursor closure and rediscovery deterministically instead of depending on narrow wall-clock timing windows.

Problem

A Windows-sensitive test inferred idle-cursor closure and later glob rediscovery from real-time polling with only tens of milliseconds of slack. A short scheduler stall could delay the closing poll, append the next line before rediscovery, and reopen the file at EOF, permanently skipping the line and timing out with zero events.

Approach

Adds constructor overloads that accept a LongSupplier clock while preserving System.currentTimeMillis as the production default. The test advances a manual clock beyond the inactive threshold and then one scan interval, proving closure and rediscovery in separate polls before asserting the resumed event and restarted line number.

Impact and scope

  • Removes a reproduced Windows CI race rather than masking it with a larger timeout.
  • Makes the discovery-before-close ordering explicit and repeatable in the regression test.
  • Adds a line-number assertion that proves the cursor was actually closed and reopened.
  • Preserves the production constructor path, wall-clock default, and persisted position timestamp semantics.
  • Introduces no user-facing API, configuration, protocol, or connector behavior change.

Validation

  • A forced timing window failed 15 of 20 JDK 8 runs and 7 of 20 JDK 11 runs on the unchanged baseline, then passed 20 of 20 per JDK with the manual-clock change.
  • The patched test passed 200 of 200 stressed runs on both JDK 8 and JDK 11; mutation checks failed when either cursor closure or rediscovery was removed.
  • The connector and starter module builds passed 141 tests plus Spotless on both tested JDKs. All four hosted checks passed, and an Apache SeaTunnel member approved and merged the authored change.