-
Notifications
You must be signed in to change notification settings - Fork 153
Description
After updating to maven 3.9.6, and Fedora 43, with JDK 21, color output in terminal is not working. After debugging maven, I found the problem is in the JansiLoader.contentsEquals method:
if (!Arrays.equals(buffer1, buffer2)) {
return "Content differs";
}
It seems that previously, when reading from an input stream into a buffer, if the number of bytes read is less than the buffer's length, the remaining bytes were reset to zero. Nowadays, it seems just the bytes read are overwritten. The number of bytes read is returned by the readNBytes method, but its output is not taken into account when comparing the arrays, causing the mismatch and preventing the native library from being loaded from inside the jar and used to produce color output in the console.
The comparison should use the number of bytes read instead of ignoring it. There's a method that allows to do this directly in JDK 9:
if (!Arrays.equals(buffer1, 0, numRead1, buffer2, 0, numRead2)) {
return "Content differs";
}
However, I see the target of the library is JDK8. I've submitted a patch that requires JDK 9 as a minimum for the library, but I'm not sure if that's ok. If JDK 8 compatibility is required, then the alternative is to zero out the buffers before reading in the readNBytes method. Let me know the best approach to handle this.
Here's the PR for review: #316