{"record":{"id":"3abe169585b9fdb0","repo":"oracle/graal","slug":"getmark","errorCode":null,"errorMessage":"getMark","messagePattern":"getMark","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/StreamSource.java","lineNumber":144,"sourceCode":"            return null;\n        }\n        return readBytes(len);\n    }\n\n    @Override\n    public byte[] readBytes(int len) throws IOException {\n        return readBytes(new byte[len], len);\n    }\n\n    @Override\n    public byte[] readBytes(byte[] b, int len) throws IOException {\n        in.readFully(b, 0, len);\n        return b;\n    }\n\n    @Override\n    public long getMark() {\n        throw new UnsupportedOperationException(\"getMark\");\n    }\n\n    private void setVersion(int newMajorVersion, int newMinorVersion) throws IOException {\n        if (newMajorVersion > CURRENT_MAJOR_VERSION || (newMajorVersion == CURRENT_MAJOR_VERSION && newMinorVersion > CURRENT_MINOR_VERSION)) {\n            throw new VersionMismatchException(\"File format version \" + versionPair(newMajorVersion, newMinorVersion) + \" unsupported.  Current version is \" + CURRENT_VERSION);\n        }\n        majorVersion = newMajorVersion;\n        minorVersion = newMinorVersion;\n    }\n\n    @Override\n    public int getMajorVersion() {\n        return majorVersion;\n    }\n\n    public int getMinorVersion() {\n        return minorVersion;\n    }","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/StreamSource.java#L126-L162","documentation":"StreamSource is a streaming (non-seekable) DataSource over a DataInputStream and cannot report a position/mark in the input. getMark() is part of the DataSource interface (needed by random-access sources) but is deliberately unimplemented here; any reader that calls it to resume or re-read a graph dump fails immediately.","triggerScenarios":"Calling DataSource.getMark() on an instance of StreamSource (e.g. a GraphReader constructed over a plain InputStream instead of a File or RandomAccessFile-based source), then attempting to seek back or re-parse a group at a recorded mark.","commonSituations":"Pointing the graph reader (IdealGraphParser/GraphReader) at System.in, a socket, a gzipped stream, or any InputStream rather than a file path; tools that re-read earlier graph groups.","solutions":["Use a random-access source (file-based DataSource, e.g. the reader opened from a File) instead of StreamSource when the parser needs marks","Buffer the whole stream into a byte[] and re-create a source over it if the input is not a file","If you own the reader logic, avoid getMark()-dependent re-parse paths for stream inputs"],"exampleFix":"// before\nDataSource src = new StreamSource(socket.getInputStream());\nlong mark = src.getMark(); // UnsupportedOperationException\n\n// after\nPath tmp = Files.createTempFile(\"graph\", \".bgv\");\ntry (InputStream in = socket.getInputStream()) {\n    Files.copy(in, tmp, StandardCopyOption.REPLACE_EXISTING);\n}\nDataSource src = new FileSource(tmp.toFile()); // supports getMark","handlingStrategy":"try-catch","validationCode":"boolean supportsMarks(DataSource src) { return !(src instanceof jdk.graal.compiler.graphio.parsing.StreamSource); }","typeGuard":null,"tryCatchPattern":"try { long m = src.getMark(); } catch (UnsupportedOperationException e) { /* fall back to non-seekable parsing or re-open from a file */ }","preventionTips":["Open graph readers from File/random-access sources when re-parsing is required","Buffer non-file streams fully before parsing","Feature-detect DataSource capabilities before using getMark"],"tags":["graphio","io","streaming","unsupported-operation"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}