jamesfredley commented on code in PR #15598:
URL: https://github.com/apache/grails-core/pull/15598#discussion_r3137407650


##########
grails-wrapper/src/main/java/grails/init/GrailsVersion.java:
##########
@@ -138,29 +190,17 @@ public static GrailsVersion getPreferredGrailsVersion() {
             System.exit(1);
         }
 
-        if (!properties.containsKey("grailsVersion")) {
+        if (!properties.containsKey(GRAILS_VERSION_PROPERTY)) {
             return null;
         }
 
-        String grailsVersion = properties.getProperty("grailsVersion");
-        if (grailsVersion == null) {
-            String overrideGrailsVersion = 
System.getenv("PREFERRED_GRAILS_VERSION");
-            if (overrideGrailsVersion != null) {
-                try {
-                    return new GrailsVersion(overrideGrailsVersion);
-                } catch (Exception e) {
-                    System.out.println("An invalid Grails Version [" + 
overrideGrailsVersion + "] was specified in PREFERRED_GRAILS_VERSION");
-                    e.printStackTrace();
-                    System.exit(1);
-                }
-            }
-
-            System.out.println("gradle.properties does not contain 
grailsVersion; assuming latest Grails Version");
+        String grailsVersion = properties.getProperty(GRAILS_VERSION_PROPERTY);
+        if (grailsVersion == null || grailsVersion.trim().isEmpty()) {
             return null;

Review Comment:
   Fixed in 791866172a. Agree the silent fallthrough violated the documented 
precedence and could mask a project misconfiguration (env var silently winning 
inside a project). Aligned blank handling with the existing unparseable-version 
handling on the same code path: print a diagnostic and `System.exit(1)`. Also 
clarified the Javadoc to explicitly require a non-blank value and added a 
data-driven Spock spec covering empty, whitespace-only, and key-without-`=` 
cases.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to