Skip to content

StringIndexOutOfBoundsException after switching to nREPL 1.5.0 #3844

@rrudakov

Description

@rrudakov

Expected behavior

Any string can be printed to the REPL without errors.

Actual behavior

Printing certain strings cause StringIndexOutOfBoundsException

Steps to reproduce the problem

I started seeing these exception after updating to nREPL 1.5.0 with timbre, but I figured that timbre is not the root cause. I've captured the problematic output to a file using:

(let [string-writer (java.io.StringWriter.)] (binding [*err* string-writer] (log/error e message)) (spit "problem.txt" (.toString string-writer)))

To reproduce the issue:

  • Download the attached file:

problem.txt

  • Eval in the REPL:
(println (slurp "problem.txt"))

Error:

Execution error (StringIndexOutOfBoundsException) at jdk.internal.util.Preconditions$1/apply (Preconditions.java:55). Range [0, 1024) out of bounds for length 1020 Exception in thread "nREPL-session-09e36291-98d2-4c2c-99e6-ae3119e6636f" java.lang.StringIndexOutOfBoundsException: Range [0, 1024) out of bounds for length 1020	at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)	at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)	at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)	at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)	at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4937)	at java.base/java.lang.String.substring(String.java:2899)	at nrepl.out.CallbackBufferedOutputStream.maybeFlush(CallbackBufferedOutputStream.java:75) at nrepl.out.CallbackBufferedOutputStream.flush(CallbackBufferedOutputStream.java:52)	at java.base/sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:321)	at java.base/sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:150)	at java.base/java.io.OutputStreamWriter.flush(OutputStreamWriter.java:249)	at java.base/java.io.PrintWriter.flush(PrintWriter.java:380)	at clojure.core$flush.invokeStatic(core.clj:3737)	at clojure.core$flush.invoke(core.clj:3731)	at nrepl.middleware.interruptible_eval$evaluator$run__7460.invoke(interruptible_eval.clj:157) 

Environment & Version information

CIDER version information

;; CIDER 1.20.0-snapshot (package: 20251016.1722), nREPL 1.5.0 ;; Clojure 1.12.3, Java 25 

Lein / Clojure CLI version

Clojure CLI 1.12.3

Emacs version

31 (master)

Operating system

MacOS

JDK distribution

openjdk version "25" 2025-09-16 LTS OpenJDK Runtime Environment Temurin-25+36 (build 25+36-LTS) OpenJDK 64-Bit Server VM Temurin-25+36 (build 25+36-LTS, mixed mode, sharing) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions