It can be easily reproduced with the following test:
Both tests will pass under Intellij, writing "fun" and "fun times" to System.out. Whereas, with Surefire capturing standard out when running from maven, only fun_times() passes. fun() will fail with:
If you look at the Javadoc contract for PrintStream.write(byte buf, int off, int len), you can see that len is "Number of bytes to write", so you can see that it should be fine to print the substring "fun", of length 3, at offset 5. And indeed that is what happens in Intellij.
I suspect that the failing test isolates the problem to when the offset "exceeds" the length of the substring. The wrong length is being checked in StringUtils.escapeBytesToPrintable(). I think that the check intended to ensure the offset didn't exceed the end of the byte array, not the length of the slice. But that is already covered by "off >= input.length". So there is no benefit to also checking "off > len".