quarkusio/quarkus · error · IllegalStateException

End of line unexpected at " + lineNumber + ":" + pos

Error message

End of line unexpected at " + lineNumber + ":" + pos

What it means

After consuming a full line, the parser checks leftover buffered text. If a non-empty buffer remains while the state is neither COMMAND nor PARAM (e.g. mid-quote or inside an unexpected state), the line ended in an incomplete construct and the loader throws IllegalStateException with the line and position.

Solutions

  1. Inspect the reported line for an unterminated quote or truncated token and complete it
  2. Ensure the file was transferred/copied fully (compare size/checksum with the source)
  3. Add a trailing newline at end of file if the last line was cut mid-token
  4. Rewrite the offending line as a complete single-line command

Example fix

// before (import.redis)
SET greeting "hello // unterminated quote
// after
SET greeting hello // complete, well-formed line
Defensive patterns

Strategy: validation

Validate before calling

List<String> lines = java.nio.file.Files.readAllLines(java.nio.file.Path.of(path));
for (int i = 0; i < lines.size(); i++) {
    String line = lines.get(i);
    long quotes = line.chars().filter(c -> c == '"').count();
    if (quotes % 2 != 0) {
        throw new IllegalStateException("Unbalanced quotes at line " + (i + 1) + ": " + line);
    }
}
if (!Files.readString(Path.of(path)).endsWith("\n")) {
    throw new IllegalStateException("Import file should end with a newline");
}

Try / catch

try {
    RedisDataLoader.load(vertx, redis, path);
} catch (IllegalStateException e) {
    log.error("Incomplete line in import script: " + e.getMessage());
}

Prevention

When it happens

Trigger: An import file line ends with an unterminated quoted argument (opening quote never closed); a line ends immediately after an opening marker/token leaving the parser in a state where trailing text is invalid; truncated file (last line cut off mid-token).

Common situations: Truncated upload or partial copy/paste of the import script; unterminated quote due to shell escaping; file edited with an editor that stripped the final newline or characters.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/6bec2747fb81ca06. Report an issue: GitHub.

Appendix: source

Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/RedisDataLoader.java:122

                if (c != '"') {
                    current.append(c);
                } else {
                    request.arg(getAndClear(current));
                    state = State.ARGUMENTS;
                }
            } else {
                throw new IllegalStateException("Unexpected character at " + lineNumber + ":" + pos
                        + ", current state is " + state.name());
            }
        }

        if (current.length() > 0) {
            if (state == State.COMMAND) {
                request = Request.cmd(Command.create(getAndClear(current)));
            } else if (state == State.PARAM) {
                request.arg(getAndClear(current));
            } else {
                throw new IllegalStateException("End of line unexpected at " + lineNumber + ":" + pos);
            }
        }

        return request;

    }

    private static String getAndClear(StringBuffer buffer) {
        var content = buffer.toString();
        buffer.setLength(0);
        return content;
    }

}

View on GitHub (pinned to e1c734241f)