seaweedfs/seaweedfs · error · IllegalArgumentException
In is not an instance of Seekable or PositionedReadable
Error message
In is not an instance of Seekable or PositionedReadable
What it means
BufferedByteBufferReadableInputStream's constructor asserts that the wrapped FSInputStream implements both Seekable and PositionedReadable — the minimum Hadoop requires of a seekable buffered stream. Passing anything else (a stream type that only superficially extends FSInputStream, a dynamic proxy, or a mock) fails fast with IllegalArgumentException before the first read.
Source
Thrown at other/java/hdfs3/src/main/java/seaweed/hdfs/BufferedByteBufferReadableInputStream.java:13
package seaweed.hdfs;
import org.apache.hadoop.fs.*;
import java.io.IOException;
import java.nio.ByteBuffer;
public class BufferedByteBufferReadableInputStream extends BufferedFSInputStream implements ByteBufferReadable {
public BufferedByteBufferReadableInputStream(FSInputStream in, int size) {
super(in, size);
if (!(in instanceof Seekable) || !(in instanceof PositionedReadable)) {
throw new IllegalArgumentException("In is not an instance of Seekable or PositionedReadable");
}
}
@Override
public int read(ByteBuffer buf) throws IOException {
if (this.in instanceof ByteBufferReadable) {
return ((ByteBufferReadable)this.in).read(buf);
} else {
throw new UnsupportedOperationException("Byte-buffer read unsupported by input stream");
}
}
}
View on GitHub (pinned to 1c926e8fac)
Solutions
- Wrap the real SeaweedInputStream (it implements both interfaces) instead of an intermediate custom stream
- For mocks, make them implement Seekable and PositionedReadable or use FSDataInputStream in tests
- Align Hadoop versions across the classpath so instanceof checks see the same interface types
Example fix
// before new BufferedByteBufferReadableInputStream(customSockStream, size); // customSockStream lacks interfaces // after FSInputStream in = (customSockStream instanceof Seekable && customSockStream instanceof PositionedReadable) ? customSockStream : new seaweedFileSystemStore.openFileForRead(path, stats); new BufferedByteBufferReadableInputStream(in, size);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(in instanceof Seekable) || !(in instanceof PositionedReadable)) {
throw new IllegalArgumentException("inner stream must be Seekable + PositionedReadable: " + in.getClass());
} Type guard
static boolean wrappable(FSInputStream in) {
return in instanceof Seekable && in instanceof PositionedReadable;
} Prevention
- Wrap the real SeaweedInputStream; do not interpose custom stream shims
- Make test mocks implement Seekable and PositionedReadable
- Keep one Hadoop version on the classpath so interface identity is stable
When it happens
Trigger: Wrapping a custom or third-party FSInputStream subclass that does not implement these interfaces (possible via proxies or nonstandard filesystems); unit tests passing mocked streams; wiring a raw socket-backed stream into this buffer layer.
Common situations: Test harnesses with Mockito mocks of FSInputStream; custom filesystem shims layered over the seaweed client; dependency conflicts pulling an old Hadoop version where interface hierarchies differ.
Related errors
- Byte-buffer read unsupported by input stream
- Failed to open file: {path}
- Failed to create file: {path}
- Not a directory: {parent}
- Failed to append to file: {path}
AI-assisted analysis of seaweedfs/seaweedfs@1c926e8fac (2026-08-15).
Data as JSON: /api/errors/d8cf76b0f8a89510.
Report an issue: GitHub.