deeplearning4j/deeplearning4j · error · RuntimeException

null

Error message

null

What it means

nextSequence() opens the next URI via the configured stream creator and reads the whole file with IOUtils.toString; any IOException is wrapped and rethrown as a RuntimeException with the underlying exception's (possibly null) message. A message of "null" means the wrapped I/O failure carried no detail, most commonly a NullPointerException on the stream or an I/O error without a message. It signals the sequence data source could not be read.

Solutions

  1. Verify every URI in the InputSplit exists and is readable before iterating (Files.exists / FileSystem.checkPath)
  2. Check that the stream creator lambda passed to the reader supports the URI scheme (file://, hdfs://, etc.)
  3. Call nextSequence() inside try/catch for RuntimeException and inspect getCause() for the real IOException/NPE
  4. Re-initialize the reader after files change so locationsIterator reflects the current filesystem

Example fix

// before
SequenceRecord r = reader.nextSequence(); // throws RuntimeException(null)
// after
if (!new File(uri).exists()) { LOG.warn("Skipping missing file: " + uri); continue; }
try { SequenceRecord r = reader.nextSequence(); } catch (RuntimeException e) { throw new RuntimeException("Failed reading " + uri, e.getCause()); }
Defensive patterns

Strategy: try-catch

Validate before calling

if (!Files.isReadable(Paths.get(uri))) { throw new IOException("Sequence file missing or unreadable: " + uri); }

Try / catch

try { seq = reader.nextSequence(); } catch (RuntimeException e) { Throwable c = e.getCause(); if (c instanceof IOException) { LOG.error("I/O failure reading sequence: " + c.getMessage(), c); } else if (c == null || c instanceof NullPointerException) { LOG.error("Stream creator returned null stream for URI"); } throw e; }

Prevention

When it happens

Trigger: Calling nextSequence() (directly or via sequenceRecord) when locationsIterator.next() returns a URI whose stream cannot be opened (missing file, bad path/URI scheme, streamCreatorFn returns null) or the stream fails mid-read with a message-less IOException.

Common situations: InputSplit pointing to files deleted or moved after split creation; unsupported URI scheme for the stream creator; HDFS/local path permissions; reading a directory instead of a file.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of deeplearning4j/deeplearning4j@4c22ac5fe4 (2026-09-07). Data as JSON: /api/errors/076dd287e5b74a18. Report an issue: GitHub.

Appendix: source

Thrown at datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/regex/RegexSequenceRecordReader.java:157

        return out;
    }

    @Override
    public void reset() {
        super.reset();
    }

    @Override
    public SequenceRecord nextSequence() {
        Preconditions.checkState(hasNext(), "No next element available");
        URI next = locationsIterator.next();

        String fileContents;
        try (InputStream s = streamCreatorFn.apply(next)){
            fileContents = IOUtils.toString(s, charset);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        List<List<Writable>> sequence = loadSequence(fileContents, next);
        return new org.datavec.api.records.impl.SequenceRecord(sequence, new RecordMetaDataURI(next, RegexSequenceRecordReader.class));
    }

    @Override
    public SequenceRecord loadSequenceFromMetaData(RecordMetaData recordMetaData) throws IOException {
        return loadSequenceFromMetaData(Collections.singletonList(recordMetaData)).get(0);
    }

    @Override
    public List<SequenceRecord> loadSequenceFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
        List<SequenceRecord> out = new ArrayList<>();
        for (RecordMetaData meta : recordMetaDatas) {
            File next = new File(meta.getURI());
            URI uri = next.toURI();
            String fileContents = FileUtils.readFileToString(next, charset.name());
            List<List<Writable>> sequence = loadSequence(fileContents, uri);

View on GitHub (pinned to 4c22ac5fe4)