{"record":{"id":"bec8e469d943558a","repo":"apache/beam","slug":"onwindowexpirationcontext-unsupported-in-s","errorCode":null,"errorMessage":"OnWindowExpirationContext unsupported in %s","messagePattern":"OnWindowExpirationContext unsupported in (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnInvoker.java","lineNumber":458,"sourceCode":"          String.format(\"FinishBundleContext unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public DoFn<InputT, OutputT>.OnTimerContext onTimerContext(DoFn<InputT, OutputT> doFn) {\n      throw new UnsupportedOperationException(\n          String.format(\"OnTimerContext unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public DoFn<InputT, OutputT>.OnWindowExpirationContext onWindowExpirationContext(\n        DoFn<InputT, OutputT> doFn) {\n      throw new UnsupportedOperationException(\n          String.format(\"OnWindowExpirationContext unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public State state(String stateId, boolean alwaysFetched) {\n      throw new UnsupportedOperationException(\n          String.format(\"State unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public Timer timer(String timerId) {\n      throw new UnsupportedOperationException(\n          String.format(\"Timer unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public RestrictionTracker<?, ?> restrictionTracker() {\n      throw new UnsupportedOperationException(\n          String.format(\"RestrictionTracker unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public Object watermarkEstimatorState() {\n      throw new UnsupportedOperationException(","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnInvoker.java#L440-L476","documentation":"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.","triggerScenarios":"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.","commonSituations":"Runners that have not implemented @OnWindowExpiration support; tests hand-rolling invoker bases; invoking the accessor outside the window-expiration lifecycle.","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"],"exampleFix":"// before\ninvoker.onWindowExpirationContext(fn); // throws on stub invoker\n// after\nif (runnerSupportsWindowExpiration) { DoFnInvokers.tryInvokeFor(fn).onWindowExpirationContext(fn); }","handlingStrategy":"validation","validationCode":"if (signature.getMethodElement().equals(\"OnWindowExpiration\")) {\n  checkRunnerSupportsWindowExpiration();\n}","typeGuard":"boolean supportsWindowExpiration(DoFnInvoker<?, ?> i) {\n  return !(i instanceof DoFnInvoker.BaseDoFnInvoker);\n}","tryCatchPattern":"try {\n  ctx = invoker.onWindowExpirationContext(doFn);\n} catch (UnsupportedOperationException e) {\n  // runner lacks window-expiration support\n  handleMissingContext(e);\n}","preventionTips":["Confirm runner window-expiration support before using @OnWindowExpiration","Do not request window-expiration context in other phases","Build invokers through DoFnInvokers only"],"tags":["java","apache-beam","unsupported-operation","window-expiration"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}