Skip to content

Match a distribution whose candidate carries a vendor build - #1225

Merged
jkschneider merged 1 commit into
mainfrom
sdkman-build-metadata
Aug 24, 2026
Merged

Match a distribution whose candidate carries a vendor build#1225
jkschneider merged 1 commit into
mainfrom
sdkman-build-metadata

Conversation

@jkschneider

Copy link
Copy Markdown
Member

UpdateSdkManTest has four failures on main, which fail every open PR. They are not caused by any of them.

What happened

The automated candidate refresh ([Auto] SDKMAN! Java candidates as of 2026-08-24T1031, 4d52274) changed identifiers to carry the vendor build:

-11.0.32-zulu     +11.0.32+1.1-zulu
-17.0.20-zulu     +17.0.20+1.1-zulu

38 of the 92 candidates now have one, across -zulu, -ms and -librca.

Why it breaks distribution matching

VersionComparator.RELEASE_PATTERN captures the qualifier as (?<qualifier>[-.+].*?$), so it begins at the first -, . or +. The recipe passes the distribution to LatestRelease as the metadata pattern, and checkVersion requires the whole qualifier to match it:

candidate qualifier matches -zulu
17.0.20-zulu -zulu yes
17.0.20+1.1-zulu +1.1-zulu no

Every candidate for the requested distribution is filtered out, no ideal candidate is found, and the recipe makes no change — which is what the four tests report.

Fix

Tolerate a build ahead of the distribution when matching:

private static final String BUILD_METADATA = "(\\+[^-]*)?";

Deliberately narrow rather than .*. A distribution variant is also part of the qualifier — .crac-zulu is a different distribution from -zulu, and zuluNonCrac exists to assert that a plain request does not select the CRaC build. .*-zulu would match it and quietly break that guarantee; (\+[^-]*)?-zulu cannot, because a variant does not begin with +.

The same pattern is used for the downgrade check, so both sides of the comparison agree on what the distribution is.

Tests

distributionIsStillMatchedWhenTheCandidateCarriesAVendorBuild covers an .sdkmanrc that already pins a build, and zuluNonCrac gains an explicit doesNotContain(".crac") so the narrowness above is asserted rather than assumed.

Reverting only the main source fails five tests including the two above; with the fix, UpdateSdkManTest is 18/18 and the full suite is green.

Worth noting separately

An fx candidate now reads 11.0.32-fx+1.1-librca, where the build sits after the variant. A request whose distribution is .fx-librca still will not match it, since the build is not adjacent to the distribution in that layout. No test covers that shape today and none of the current failures involve it, so it is left alone here rather than guessed at.

SDKMAN candidates now read `17.0.20+1.1-zulu`, and the build lands in the
qualifier that the distribution is matched against, so no candidate for the
requested distribution survives the filter and the recipe stops upgrading.

Only a build is tolerated ahead of the distribution rather than anything at all:
a variant such as `.crac-zulu` is a distinct distribution, and a plain request
should keep on not selecting it.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Aug 24, 2026
@jkschneider
jkschneider merged commit b2c555b into main Aug 24, 2026
1 check passed
@jkschneider
jkschneider deleted the sdkman-build-metadata branch August 24, 2026 13:58
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant