apache/beam · error · UnsupportedOperationException
OnWindowExpirationContext unsupported in
Error message
OnWindowExpirationContext unsupported in %s
What it means
Requesting OnWindowExpirationContext from a DoFnInvoker that is the stub 'unsupported' base throws UnsupportedOperationException. This context is only produced by runners that support window expiration callbacks, so the base class refuses by default and getErrorContext() reports where the access was attempted.
Solutions
- Create the invoker via DoFnInvokers so the concrete accessor is used
- Use a runner that implements window expiration if the DoFn declares @OnWindowExpiration
- Remove @OnWindowExpiration usage if the target runner cannot supply the context
Example fix
// before
invoker.onWindowExpirationContext(fn); // throws on stub invoker
// after
if (runnerSupportsWindowExpiration) { DoFnInvokers.tryInvokeFor(fn).onWindowExpirationContext(fn); } Defensive patterns
Strategy: validation
Validate before calling
if (signature.getMethodElement().equals("OnWindowExpiration")) {
checkRunnerSupportsWindowExpiration();
} Type guard
boolean supportsWindowExpiration(DoFnInvoker<?, ?> i) {
return !(i instanceof DoFnInvoker.BaseDoFnInvoker);
} Try / catch
try {
ctx = invoker.onWindowExpirationContext(doFn);
} catch (UnsupportedOperationException e) {
// runner lacks window-expiration support
handleMissingContext(e);
} Prevention
- Confirm runner window-expiration support before using @OnWindowExpiration
- Do not request window-expiration context in other phases
- Build invokers through DoFnInvokers only
When it happens
Trigger: Calling onWindowExpirationContext(...) on an invoker lacking an override, typically because the invoker was instantiated from the base class directly or the runner has no window-expiration support.
Common situations: Runners that have not implemented @OnWindowExpiration support; tests hand-rolling invoker bases; invoking the accessor outside the window-expiration lifecycle.
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
- BoundedWindow unsupported in
- Cannot access fire timestamp outside of @OnTimer method.
- Cannot access OnTimerContext outside of @OnTimer methods.
- Cannot access OnWindowExpirationContext outside of…
- Cannot access time domain outside of @ProcessTimer method.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/bec8e469d943558a.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnInvoker.java:458
String.format("FinishBundleContext unsupported in %s", getErrorContext()));
}
@Override
public DoFn<InputT, OutputT>.OnTimerContext onTimerContext(DoFn<InputT, OutputT> doFn) {
throw new UnsupportedOperationException(
String.format("OnTimerContext unsupported in %s", getErrorContext()));
}
@Override
public DoFn<InputT, OutputT>.OnWindowExpirationContext onWindowExpirationContext(
DoFn<InputT, OutputT> doFn) {
throw new UnsupportedOperationException(
String.format("OnWindowExpirationContext unsupported in %s", getErrorContext()));
}
@Override
public State state(String stateId, boolean alwaysFetched) {
throw new UnsupportedOperationException(
String.format("State unsupported in %s", getErrorContext()));
}
@Override
public Timer timer(String timerId) {
throw new UnsupportedOperationException(
String.format("Timer unsupported in %s", getErrorContext()));
}
@Override
public RestrictionTracker<?, ?> restrictionTracker() {
throw new UnsupportedOperationException(
String.format("RestrictionTracker unsupported in %s", getErrorContext()));
}
@Override
public Object watermarkEstimatorState() {
throw new UnsupportedOperationException(View on GitHub (pinned to 12126d8942)