{"record":{"id":"2d30460b428d6c8b","repo":"neo4j/neo4j","slug":"not-supported-in-storage-channels","errorCode":null,"errorMessage":"Not supported in storage channels","messagePattern":"Not supported in storage channels","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"community/cloud/src/main/java/org/neo4j/cloud/storage/StorageChannel.java","lineNumber":77,"sourceCode":"        return write(srcs, 0, srcs.length);\n    }\n\n    @Override\n    public long write(ByteBuffer[] srcs, int offset, int length) throws IOException {\n        Preconditions.checkArgument(\n                offset >= 0 && offset < srcs.length, \"Offset must be within the range of buffers provided\");\n        Preconditions.checkArgument(\n                offset + length <= srcs.length, \"Length must be within the range of buffers provided\");\n        var written = 0L;\n        for (var i = offset; i < offset + length; i++) {\n            written += doWrite(srcs[i]);\n        }\n        return written;\n    }\n\n    @Override\n    public void writeAll(ByteBuffer src, long position) throws IOException {\n        throw new UnsupportedOperationException(\"Not supported in storage channels\");\n    }\n\n    @Override\n    public void writeAll(ByteBuffer src) throws IOException {\n        doWrite(src);\n    }\n\n    @Override\n    public StorageChannel truncate(long size) throws IOException {\n        channel.truncate(size);\n        return this;\n    }\n\n    @Override\n    public int read(ByteBuffer dst, long position) throws IOException {\n        //noinspection resource\n        return position(position).read(dst);\n    }","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/neo4j/neo4j/blob/f213380f812b820a1b312e2ea52cb3d8f1931ccc/community/cloud/src/main/java/org/neo4j/cloud/storage/StorageChannel.java#L59-L95","documentation":"StorageChannel implements a positional write API surface (it mirrors Neo4j's ReadableChannel/WritableChannel contracts) but the underlying cloud channel only supports sequential writes — remote storage is typically append/stream oriented and cannot cheaply seek-and-write. writeAll(ByteBuffer, long position) therefore throws UnsupportedOperationException to fail fast on positional semantics.","triggerScenarios":"Calling storageChannel.writeAll(src, position) — the two-argument positional variant — directly, or via framework code that uses positional writes when a channel happens to be a StorageChannel (e.g. generic copy utilities that always call the positional overload).","commonSituations":"Reusing file-copy or page-flush utilities written against StoreChannel/FileChannel with cloud storage channels; migrating code from LocalFileSystemAbstraction channels to cloud storage; third-party libs that call FileChannel-style positional writes.","solutions":["Use the sequential API: position(pos) followed by writeAll(src) (single-argument), which is supported","Rewrite generic copy helpers to check channel type and use sequential writes for StorageChannel","Buffer writes in memory (or a local temp channel) and stream them sequentially to storage"],"exampleFix":"// before\nchannel.writeAll(buffer, 42L); // throws\n\n// after\nchannel.position(42L);\nchannel.writeAll(buffer);","handlingStrategy":"validation","validationCode":"void writeAllAt(StorageChannel ch, ByteBuffer src, long pos) throws IOException {\n    ch.position(pos);          // supported\n    ch.writeAll(src);          // sequential overload, supported\n}","typeGuard":"static boolean supportsPositionalWrite(ReadableChannel ch) {\n    return !(ch instanceof org.neo4j.cloud.storage.StorageChannel);\n}","tryCatchPattern":"catch (UnsupportedOperationException e) on writeAll(src, pos): retry once via position(pos)+writeAll(src); rethrow if that also fails.","preventionTips":["Write IO helpers against the sequential overloads only","Type-check channels in shared copy utilities before choosing positional overloads","Keep a lint/review check for the two-argument writeAll/readAll on abstraction-provided channels"],"tags":["channel","io","positional-write","cloud-storage"],"backgroundTag":null,"analyzedSha":"f213380f812b820a1b312e2ea52cb3d8f1931ccc","analyzedAt":"2026-08-14T15:32:33.859Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}