The GitHub Actions job "CI" on 
grails-core.git/fix/wrapper-verify-pin-branch-snapshot has succeeded.
Run started by GitHub user jamesfredley (triggered by jamesfredley).

Head commit for run:
fd73cf35f2f8b7cd47a4ed5a3c867b1b18eb0442 / James Fredley 
<[email protected]>
Throw IllegalStateException instead of System.exit on wrapper misconfiguration

The `grails-wrapper:test` spec `preferred version - blank grailsVersion in 
gradle.properties` has been failing on every JDK 21+ matrix cell (ubuntu-21/25, 
macos-21, windows-25) since the test was introduced. The failure is a 
`java.lang.UnsupportedOperationException: The Security Manager is deprecated 
and will be removed in a future release` thrown from 
`System.setSecurityManager` inside `SystemStubs.catchSystemExit`.

The Security Manager was marked terminally deprecated in JEP 411 (JDK 17), 
disabled by default in JDK 18, throws without `-Djava.security.manager=allow` 
on JDK 21, and is slated for permanent removal in JDK 24+ (JEP 486). There is 
no version-portable way to keep `catchSystemExit` working, and the test passes 
on JDK 17 only because the deprecation stays in effect as a warning on that 
release.

Fix by removing the need for `catchSystemExit` entirely:

* `getPreferredGrailsVersion(File)` (package-private, testable) and 
`readVersionFromProperties` now throw `IllegalStateException` on the four 
misconfiguration paths (unreadable properties, blank `grailsVersion`, 
unparseable `grailsVersion`, unparseable `PREFERRED_GRAILS_VERSION`).

* The public no-arg `getPreferredGrailsVersion()` is the single call site that 
still performs the CLI-level `System.exit(1)`: it catches 
`IllegalStateException`, prints `e.getMessage()`, prints 
`e.getCause().printStackTrace()` when present, then exits. The user-visible 
wrapper behaviour is unchanged.

* The Spock spec asserts `thrown(IllegalStateException)` directly and pins the 
message so future wording drift surfaces as a test failure. No JVM-level 
interception is needed; `SystemStubs.catchSystemExit` is no longer referenced 
anywhere in `grails-wrapper`.

Also move `.trim()` up to the variable definition for `grailsVersion` and 
`overrideGrailsVersion` so the trimmed form is used consistently throughout 
each method and the raw form survives only for inclusion in the error message 
(addresses jdaugherty review comment on PR #15598).

All 23 `:grails-wrapper:test` specs pass locally with the default JDK; the 
three previously failing blank-grailsVersion data-rows now pass without relying 
on the Security Manager.

Assisted-by: claude-code:claude-opus-4-6

Report URL: https://github.com/apache/grails-core/actions/runs/24907940263

With regards,
GitHub Actions via GitBox

Reply via email to