Skip to content

Fix buffer comparison in JansiLoader.#316

Closed
rober710 wants to merge 1 commit intofusesource:masterfrom
rober710:fix-buffer-comparison
Closed

Fix buffer comparison in JansiLoader.#316
rober710 wants to merge 1 commit intofusesource:masterfrom
rober710:fix-buffer-comparison

Conversation

@rober710
Copy link
Copy Markdown

@rober710 rober710 commented Dec 22, 2025

Color output in maven stopped working some time ago in Fedora. I don't remember if the issue started happening in Fedora 41 or Fedora 43, though.

Debugging the issue, it seems that (at least with JDK 21), reading n bytes from an input stream, where n is lower than the buffer length, doesn't clear the remaining buffer with zeroes, leaving those bytes as were retrieved from a previous read. This causes the comparison in JansiLoader.contentsEquals to fail, as it's comparing the full buffer length, instead of taking into account the number of bytes read in each iteration.

I'm seing the JDK target in the pom as 8, but in the github actions, I see the JDK is 9 and 11. May I update the target in the pom to JDK 9 as well? That allows me to use the equals method that supports comparing ranges. Otherwise, I'll have to manually clear the buffer with zeroes before reading, so that the comparison works.

@rober710 rober710 force-pushed the fix-buffer-comparison branch from 3a78d57 to 92cfb29 Compare December 22, 2025 19:25
@rober710 rober710 closed this Mar 30, 2026
@rober710 rober710 deleted the fix-buffer-comparison branch March 30, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant