{"record":{"id":"d6d81998ffa992bc","repo":"apache/beam","slug":"unsupportedoperationexception","errorCode":null,"errorMessage":"UnsupportedOperationException","messagePattern":"UnsupportedOperationException","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/fn/data/BeamFnDataInboundObserver.java","lineNumber":115,"sourceCode":"    for (TimerEndpoint<?> endpoint : timerEndpoints) {\n      transformIdToTimerFamilyIdToTimerEndpoint\n          .computeIfAbsent(endpoint.getTransformId(), unused -> new HashMap<>())\n          .put(endpoint.getTimerFamilyId(), new EndpointStatus<>(endpoint));\n    }\n    this.queue = new CancellableQueue<>(100);\n    this.totalNumEndpoints = dataEndpoints.size() + timerEndpoints.size();\n    this.numEndpointsThatAreIncomplete = totalNumEndpoints;\n    this.consumingReceivedData = new AtomicBoolean(false);\n  }\n\n  @Override\n  public void accept(BeamFnApi.Elements elements) throws Exception {\n    queue.put(elements);\n  }\n\n  @Override\n  public void flush() throws Exception {\n    throw new UnsupportedOperationException();\n  }\n\n  @Override\n  public void close() throws Exception {\n    queue.cancel(CloseException.INSTANCE);\n  }\n\n  public boolean isConsumingReceivedData() {\n    return consumingReceivedData.get();\n  }\n\n  // Copies the elements of list to an array and removes references to elements that\n  // have been iterated past.\n  private static class DiscardingIterator<T> implements Iterator<T> {\n    private int index = 0;\n    private final @Nullable Object[] array;\n\n    DiscardingIterator(List<T> list) {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/fn/data/BeamFnDataInboundObserver.java#L97-L133","documentation":"BeamFnDataInboundObserver.flush() is unimplemented and always throws UnsupportedOperationException. This observer buffers Elements in a queue and forwards them in a background thread, so explicit flushing is not supported on this receiver.","triggerScenarios":"Calling flush() directly on a BeamFnDataInboundObserver obtained via the BeamFnData*Client factories, e.g. through generic code that flushes all receivers after writing data.","commonSituations":"Generic data-distribution code that calls receiver.flush() unconditionally; custom instrumentation or tests invoking flush on inbound observers.","solutions":["Do not call flush() on BeamFnDataInboundObserver; rely on its internal queue/thread to deliver elements.","Wrap the call in a check for the concrete observer type or catch UnsupportedOperationException for inbound receivers.","If flush semantics are required, use the outbound MultiplexingRecordView/data receiver that supports flushing."],"exampleFix":"// before\nreceiver.flush();\n// after\nif (receiver instanceof BeamFnDataInboundObserver) {\n  // flush is not supported for inbound observers\n} else {\n  receiver.flush();\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean supportsFlush = !(receiver instanceof BeamFnDataInboundObserver);","tryCatchPattern":"try { receiver.flush(); } catch (UnsupportedOperationException e) { /* inbound observer: flush unsupported */ }","preventionTips":["Only flush outbound receivers","Check the receiver type before calling flush","Rely on inbound observers' internal queueing"],"tags":["java","beam-fn","unsupported-operation","flush"],"backgroundTag":"method-not-implemented","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-15T02:17:10.978Z"}