apache/beam · error · UnsupportedOperationException

WatermarkEstimator unsupported in

Error message

WatermarkEstimator unsupported in %s

What it means

Requesting a BundleFinalizer from the stub DoFnInvoker throws UnsupportedOperationException. A BundleFinalizer is only supplied by runners that support bundle finalization callbacks, so the base class throws unconditionally. getErrorContext() reports the DoFn and phase.

Solutions

  1. Build the invoker with DoFnInvokers.tryInvokeFor and run on a runner that supports bundle finalization
  2. Obtain BundleFinalizer via the lifecycle method's parameter rather than the invoker directly
  3. If the runner does not support finalization, remove reliance on onBundleSuccess/onBundleFailure callbacks

Example fix

// before
invoker.bundleFinalizer(); // throws
// after
@ProcessElement
public void process(ProcessContext c, BundleFinalizer finalizer) { ... }
Defensive patterns

Strategy: validation

Validate before calling

if (signature.bundleFinalizerT() != null) {
  requireFinalizationCapableRunner();
}

Type guard

boolean supportsBundleFinalizer(DoFnInvoker<?, ?> i) {
  return !(i instanceof DoFnInvoker.BaseDoFnInvoker);
}

Try / catch

try {
  BundleFinalizer bf = invoker.bundleFinalizer();
} catch (UnsupportedOperationException e) {
  log.warn("Bundle finalization unavailable: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling bundleFinalizer() on an invoker without an override, or accessing it during phases where no bundle finalizer exists (e.g. onTimer, finishBundle).

Common situations: DoFns declaring @OnTimer/@BundleFinalizer-style finalization on runners lacking finalization support; unit-test invokers built from the abstract base.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/1aaaa6d47b4942c6. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnInvoker.java:488

      throw new UnsupportedOperationException(
          String.format("RestrictionTracker unsupported in %s", getErrorContext()));
    }

    @Override
    public Object watermarkEstimatorState() {
      throw new UnsupportedOperationException(
          String.format("WatermarkEstimatorState unsupported in %s", getErrorContext()));
    }

    @Override
    public WatermarkEstimator<?> watermarkEstimator() {
      throw new UnsupportedOperationException(
          String.format("WatermarkEstimator unsupported in %s", getErrorContext()));
    }

    @Override
    public BundleFinalizer bundleFinalizer() {
      throw new UnsupportedOperationException(
          String.format("BundleFinalizer unsupported in %s", getErrorContext()));
    }

    /**
     * Return a human readable representation of the current call context to be used during error
     * reporting.
     */
    public abstract String getErrorContext();
  }

  /** An {@link ArgumentProvider} that forwards all calls to the supplied {@code delegate}. */
  @Internal
  class DelegatingArgumentProvider<InputT, OutputT> extends BaseArgumentProvider<InputT, OutputT> {
    private final ArgumentProvider<InputT, OutputT> delegate;
    private final String errorContext;

    public DelegatingArgumentProvider(
        ArgumentProvider<InputT, OutputT> delegate, String errorContext) {

View on GitHub (pinned to 12126d8942)