This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/maven-3.9.x by this push:
     new 9ee39630ad [MNG-8135] Profile activation based on OS properties is no 
longer case insensitive (#1561)
9ee39630ad is described below

commit 9ee39630ad77a5218ebb5761d1911753e4705f62
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Wed Jun 5 18:09:54 2024 +0200

    [MNG-8135] Profile activation based on OS properties is no longer case 
insensitive (#1561)
    
    Backport of 0456c7c629d6fc872073268faeb77d2bde9a1b7d
    
    ---
    
    https://issues.apache.org/jira/browse/MNG-8135
---
 .../activation/OperatingSystemProfileActivator.java        |  8 ++++----
 .../activation/OperatingSystemProfileActivatorTest.java    | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git 
a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
 
b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
index a9c2c76a88..63931b7f20 100644
--- 
a/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
+++ 
b/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
@@ -109,14 +109,14 @@ public class OperatingSystemProfileActivator implements 
ProfileActivator {
                 reverse = true;
                 test = test.substring(1);
             }
-            result = actualVersion.equals(test);
+            result = actualVersion.equalsIgnoreCase(test);
         }
 
         return reverse != result;
     }
 
     private boolean determineArchMatch(String expectedArch, String actualArch) 
{
-        String test = expectedArch;
+        String test = expectedArch.toLowerCase(Locale.ENGLISH);
         boolean reverse = false;
 
         if (test.startsWith("!")) {
@@ -130,7 +130,7 @@ public class OperatingSystemProfileActivator implements 
ProfileActivator {
     }
 
     private boolean determineNameMatch(String expectedName, String actualName) 
{
-        String test = expectedName;
+        String test = expectedName.toLowerCase(Locale.ENGLISH);
         boolean reverse = false;
 
         if (test.startsWith("!")) {
@@ -144,7 +144,7 @@ public class OperatingSystemProfileActivator implements 
ProfileActivator {
     }
 
     private boolean determineFamilyMatch(String family, String actualName) {
-        String test = family;
+        String test = family.toLowerCase(Locale.ENGLISH);
         boolean reverse = false;
 
         if (test.startsWith("!")) {
diff --git 
a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivatorTest.java
 
b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivatorTest.java
index 7944e25503..dfda07c855 100644
--- 
a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivatorTest.java
+++ 
b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivatorTest.java
@@ -141,4 +141,18 @@ public class OperatingSystemProfileActivatorTest extends 
AbstractProfileActivato
         assertActivation(false, profile, newContext(null, 
newProperties("windows", "99", "amd64")));
         assertActivation(true, profile, newContext(null, 
newProperties("windows", "99", "aarch64")));
     }
+
+    public void testCapitalOsName() {
+        ActivationOS os = new ActivationOS();
+        os.setFamily("Mac");
+        os.setName("Mac OS X");
+        os.setArch("aarch64");
+        os.setVersion("14.5");
+        Profile profile = newProfile(os);
+
+        assertActivation(false, profile, newContext(null, 
newProperties("linux", "6.5.0-1014-aws", "amd64")));
+        assertActivation(false, profile, newContext(null, 
newProperties("windows", "1", "aarch64")));
+        assertActivation(false, profile, newContext(null, 
newProperties("windows", "99", "amd64")));
+        assertActivation(true, profile, newContext(null, newProperties("Mac OS 
X", "14.5", "aarch64")));
+    }
 }

Reply via email to