Skip to content

UpdateSdkMan recipe can cause Java downgrade when version in use is higher than requested #770

Closed
@steve-aom-elliott

Description

@steve-aom-elliott

rewrite-migrate-java's UpdateSdkMan recipe (used by UpgradeJavaVersion) can cause a downgrade of Java version when provided with a version number that is lower than the one already in use. To mirror the desired behavior of other version updates called by UpgradeJavaVersion (such as UpdateMavenProjectPropertyJavaVersion), it should guard against making changes if the version number already in use is higher than what is requested.

What version of OpenRewrite are you using?

  • rewrite-migrate-java v3.11.0

What is the smallest, simplest way to reproduce the problem?

Calling:
UpgradeJavaVersion with version of 17
or
UpdateSdkMan with newVersion of 17

Initial .sdkmanrc

java=24-librca

Expected .sdkmanrc

No change

Actual .sdkmanrc

java=17.0.15-librca

Are you interested in contributing a fix to OpenRewrite?

Yes, I'll put up a PR

Metadata

Metadata

Labels

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions