apache/flink · error · UnsupportedOperationException

PostVersionedIOReadableWritable cannot read from a DataInput

Error message

PostVersionedIOReadableWritable cannot read from a DataInputView.

What it means

Thrown unconditionally by PostVersionedIOReadableWritable.read(DataInputView) — the method is marked final and always throws UnsupportedOperationException. PostVersionedIOReadableWritable must sniff the first bytes of a stream to detect whether data was previously versioned, and DataInputView does not support pushback, so reading from a DataInputView is structurally unsupported. Callers must use the read(InputStream) overload instead.

Source

Thrown at flink-core/src/main/java/org/apache/flink/core/io/PostVersionedIOReadableWritable.java:90

        } else {
            InputStream streamToRead = inputStream;
            if (totalRead > 0) {
                PushbackInputStream resetStream = new PushbackInputStream(inputStream, totalRead);
                resetStream.unread(tmp, 0, totalRead);
                streamToRead = resetStream;
            }

            read(new DataInputViewStreamWrapper(streamToRead), false);
        }
    }

    /**
     * We do not support reading from a {@link DataInputView}, because it does not support pushing
     * back already read bytes.
     */
    @Override
    public final void read(DataInputView in) throws IOException {
        throw new UnsupportedOperationException(
                "PostVersionedIOReadableWritable cannot read from a DataInputView.");
    }
}

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Call read(InputStream) on PostVersionedIOReadableWritable instead of read(DataInputView).
  2. Wrap your DataInputView source as an InputStream (or use the original InputStream) before calling read.
  3. If you are inside a framework that only provides DataInputView, use a VersionedIOReadableWritable subclass instead, or buffer the data and re-expose it as a stream.

Example fix

// before
PostVersionedIOReadableWritable obj = ...;
obj.read(dataInputView); // throws

// after — pass an InputStream
obj.read(inputStream);
Defensive patterns

Strategy: validation

Validate before calling

if (obj instanceof PostVersionedIOReadableWritable) {
    // must use read(InputStream), not read(DataInputView)
    obj.read(inputStream);
}

Type guard

obj instanceof PostVersionedIOReadableWritable

Prevention

When it happens

Trigger: Invoking the inherited IOReadableWritable.read(DataInputView) contract on a PostVersionedIOReadableWritable subclass (e.g. via a generic IOReadableWritable.read dispatch); frameworks that route deserialization through DataInputView rather than InputStream.

Common situations: Generic serialization frameworks that call read(DataInputView) polymorphically without checking the concrete type; migrating code that used VersionedIOReadableWritable (which supports DataInputView) to a PostVersionedIOReadableWritable subclass.

Related errors


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