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

lkishalmi pushed a commit to branch release160
in repository https://gitbox.apache.org/repos/asf/netbeans.git

commit 367ae9dea0c01855f8a8eb076e220aa4cd15cff1
Author: Svatopluk Dedic <svatopluk.de...@oracle.com>
AuthorDate: Sun Nov 27 03:15:34 2022 +0100

    #4965: Fix issues with gradle pre-6.4 (#4995)
    
    * Fix #4965: Avoid NPE: return null for no supplier.
    
    * Improve compatibility for Gradle < 6.4
---
 .../org/netbeans/modules/gradle/tooling/GradleInternalAdapter.java   | 4 ++--
 .../org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java    | 4 +++-
 .../src/org/netbeans/modules/gradle/api/GradleBaseProjectTest.java   | 5 +++++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git 
a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/GradleInternalAdapter.java
 
b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/GradleInternalAdapter.java
index 515cfc7f1b..632321d772 100644
--- 
a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/GradleInternalAdapter.java
+++ 
b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/GradleInternalAdapter.java
@@ -111,7 +111,7 @@ public class GradleInternalAdapter {
     }
     
     public ValueAndType findPropertyValueInternal(String propName, Object val) 
{
-        return safeCall(() -> {
+        return sinceGradleOrDefault("6.4",() -> safeCall(() -> {
             if (val instanceof ProviderInternal) {
                 ProviderInternal provided = (ProviderInternal)val;
                 ValueSupplier.ExecutionTimeValue etv;
@@ -129,7 +129,7 @@ public class GradleInternalAdapter {
             } else {
                 return new ValueAndType(val != null ? val.getClass() : null, 
val);
             }
-        }, "property " + propName).orElse(null);
+        }, "property " + propName).orElse(null), null);
     }
     
     @SuppressWarnings("unchecked")
diff --git 
a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
 
b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
index 0c50fbfd40..0fd561a2cd 100644
--- 
a/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
+++ 
b/extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.java
@@ -1620,8 +1620,10 @@ class NbProjectInfoBuilder {
                 sneakyThrow(t);
                 return null;
             }
-        } else {
+        } else if (def != null) {
             return def.get();
+        } else {
+            return null;
         }
     }
     
diff --git 
a/extide/gradle/test/unit/src/org/netbeans/modules/gradle/api/GradleBaseProjectTest.java
 
b/extide/gradle/test/unit/src/org/netbeans/modules/gradle/api/GradleBaseProjectTest.java
index 2fe874a4b1..64778be87b 100644
--- 
a/extide/gradle/test/unit/src/org/netbeans/modules/gradle/api/GradleBaseProjectTest.java
+++ 
b/extide/gradle/test/unit/src/org/netbeans/modules/gradle/api/GradleBaseProjectTest.java
@@ -247,6 +247,11 @@ public class GradleBaseProjectTest extends 
AbstractGradleProjectTestCase {
         return p;
     }
     
+    public void testOldGradle611ProjectLoads() throws Exception {
+        Project p = makeProjectWithWrapper("projects/oldgradle/basic", 
"6.1.1");
+        assertProjectLoadedWithNoProblems(p, "6.1.1");
+    }
+
     public void testOldGradle683ProjectLoads() throws Exception {
         Project p = makeProjectWithWrapper("projects/oldgradle/basic", 
"6.8.3");
         assertProjectLoadedWithNoProblems(p, "6.8.3");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to