fix: typo in RequestedVersionComparator comparing v1 against itself#2528
fix: typo in RequestedVersionComparator comparing v1 against itself#2528maxandersen wants to merge 1 commit into
Conversation
The comparator used minRequestedVersion(v1) for both n1 and n2, making it unable to distinguish different version numbers. This meant that e.g. .max() across multiple //JAVA directives would not reliably pick the highest version.
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@quintesse just spotted this by random - I guess we haven't had many projects with multiple //JAVA statements. it does reveal that apparently we have code trying to pick the highest version rather than the first one, but this bug makes it actaully pick the first one - which is what I expected... so not just merging this in but something we should figure out - should first one wins or highest win? |
|
My intuition says the highest should win, because if we're including code that says it needs a higher Java version then I'd assume it wouldn't work with a lower one. Now You could say "then the main script should update its //JAVA line", and that wouldn't be wrong, but then I'd at least want a waning saying that you probably should update your //JAVA line because of a conflict... and that's more difficult than just picking the highest by default :-) |
|
At least it seems that devkitman doesn't have that particular code (most of that file was copied to devkitman) |
Bug
RequestedVersionComparator.compare()had a typo on line 361 ofJavaUtil.java:Both values were derived from
v1, so the comparator was version-blind — it could never distinguish different version numbers, only the+suffix.This affected:
Directives.javaVersion()—.max()across multiple//JAVAdirectives would not reliably pick the highest versionProjectBuilder.updateProject(Source, ...)— merging java versions from source dependencies could let a lower version silently winFix
One-character fix:
v1→v2.Added
TestRequestedVersionComparatorcovering null handling, same/different versions, exact vs open versions, andmax()selection.