apache/flink · critical · UnsupportedOperationException

Please override the method.

Error message

Please override the method.

What it means

Thrown as UnsupportedOperationException by the default implementation of submitRequestEntries in AsyncSinkWriter. This method is the core hook that concrete sink writers must override to send buffered request entries to the destination system. The base class provides a non-abstract stub that throws to fail fast if a subclass forgets to implement it.

Source

Thrown at flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/writer/AsyncSinkWriter.java:208

     * }
     *
     * }</pre>
     *
     * <p>During checkpointing, the sink needs to ensure that there are no outstanding in-flight
     * requests.
     *
     * @param requestEntries a set of request entries that should be sent to the destination
     * @param resultHandler the {@code complete} method should be called on this ResultHandler once
     *     the processing of the {@code requestEntries} are complete. Any entries that encountered
     *     difficulties in persisting should be re-queued through {@code retryForEntries} by
     *     including that element in the collection of {@code RequestEntryT}s passed to the {@code
     *     retryForEntries} method. All other elements are assumed to have been successfully
     *     persisted. In case of encountering fatal exceptions, the {@code completeExceptionally}
     *     method should be called.
     */
    protected void submitRequestEntries(
            List<RequestEntryT> requestEntries, ResultHandler<RequestEntryT> resultHandler) {
        throw new UnsupportedOperationException("Please override the method.");
    }

    /**
     * This method allows the getting of the size of a {@code RequestEntryT} in bytes. The size in
     * this case is measured as the total bytes that is written to the destination as a result of
     * persisting this particular {@code RequestEntryT} rather than the serialized length (which may
     * be the same).
     *
     * @param requestEntry the requestEntry for which we want to know the size
     * @return the size of the requestEntry, as defined previously
     */
    protected abstract long getSizeInBytes(RequestEntryT requestEntry);

    /**
     * This constructor is deprecated. Users should use {@link #AsyncSinkWriter(ElementConverter,
     * WriterInitContext, AsyncSinkWriterConfiguration, Collection, BatchCreator, RequestBuffer)}.
     */
    @Deprecated

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Override submitRequestEntries in your AsyncSinkWriter subclass to send entries to the destination.
  2. Ensure the method signature matches exactly: protected void submitRequestEntries(List<RequestEntryT> requestEntries, ResultHandler<RequestEntryT> resultHandler).
  3. If upgrading Flink versions, check the changelog for signature changes to submitRequestEntries.
  4. Call resultHandler.complete() on success, resultHandler.retryForEntries(...) for retryable failures, or resultHandler.completeExceptionally(...) for fatal errors.

Example fix

// before — missing override
class MySinkWriter extends AsyncSinkWriter<String, String> {
    // no submitRequestEntries override
}
// after — implement the method
@Override
protected void submitRequestEntries(List<String> requestEntries, ResultHandler<String> resultHandler) {
    client.sendBatch(requestEntries)
        .whenComplete((resp, err) -> {
            if (err != null) { resultHandler.completeExceptionally(err); }
            else { resultHandler.complete(); }
        });
}
Defensive patterns

Strategy: type-guard

Type guard

// Verify override exists via reflection (compile-time check is better)
try {
    Method m = writerClass.getDeclaredMethod("submitRequestEntries", List.class, ResultHandler.class);
    if (m.getDeclaringClass() == AsyncSinkWriter.class) {
        throw new IllegalStateException(writerClass.getName() + " must override submitRequestEntries");
    }
} catch (NoSuchMethodException e) {
    throw new IllegalStateException("submitRequestEntries not found", e);
}

Prevention

When it happens

Trigger: Subclassing AsyncSinkWriter without overriding submitRequestEntries(List<RequestEntryT>, ResultHandler<RequestEntryT>). When the sink's flush mechanism calls submitRequestEntries at runtime (triggered by buffer size or time threshold), the default stub throws.

Common situations: Developer creates a custom async sink by extending AsyncSinkWriter but forgets to implement the submitRequestEntries method; a refactor removes or renames the override; the method signature changed between Flink versions and the override no longer matches.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/42b8b470050c0b30. Report an issue: GitHub.