You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/05/17 07:49:20 UTC

[maven-build-cache-extension] branch master updated (01a04f4 -> abe934c)

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

gnodet pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/maven-build-cache-extension.git


    from 01a04f4  Use maven 3.9 by default, make maven4 optional using profiles (#13)
     new 0191a6f  Fix possible NPE caused by concurrency
     new abe934c  [MBUILDCACHE-20] Use local cache before remote cache

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/maven/buildcache/CacheControllerImpl.java   | 14 +++++++-------
 .../apache/maven/buildcache/RemoteCacheRepositoryImpl.java |  6 +++---
 2 files changed, 10 insertions(+), 10 deletions(-)


[maven-build-cache-extension] 02/02: [MBUILDCACHE-20] Use local cache before remote cache

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-build-cache-extension.git

commit abe934cd4088a42d778d50dc4cc0aa2385388e89
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon May 16 20:58:19 2022 +0200

    [MBUILDCACHE-20] Use local cache before remote cache
---
 .../org/apache/maven/buildcache/CacheControllerImpl.java   | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java b/src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java
index 8cfb145..2e5762b 100644
--- a/src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java
+++ b/src/main/java/org/apache/maven/buildcache/CacheControllerImpl.java
@@ -166,22 +166,22 @@ public class CacheControllerImpl implements CacheController
         ProjectsInputInfo inputInfo = projectInputCalculator.calculateInput( project );
 
         final CacheContext context = new CacheContext( project, inputInfo, session );
-        // remote build first
-        CacheResult result = findCachedBuild( mojoExecutions, context );
+        // local build first
+        CacheResult result = findLocalBuild( mojoExecutions, context );
 
         if ( !result.isSuccess() && result.getContext() != null )
         {
-            LOGGER.debug( "Remote cache is incomplete or missing, trying local build" );
+            LOGGER.debug( "Local cache is incomplete or missing, trying remote build" );
 
-            CacheResult localBuild = findLocalBuild( mojoExecutions, context );
+            CacheResult remoteBuild = findCachedBuild( mojoExecutions, context );
 
-            if ( localBuild.isSuccess() || ( localBuild.isPartialSuccess() && !result.isPartialSuccess() ) )
+            if ( remoteBuild.isSuccess() || ( remoteBuild.isPartialSuccess() && !result.isPartialSuccess() ) )
             {
-                result = localBuild;
+                result = remoteBuild;
             }
             else
             {
-                LOGGER.info( "Local build was not found by checksum " + inputInfo.getChecksum() );
+                LOGGER.info( "Remote build was not found by checksum " + inputInfo.getChecksum() );
             }
         }
         cacheResults.put( getVersionlessProjectKey( project ), result );


[maven-build-cache-extension] 01/02: Fix possible NPE caused by concurrency

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-build-cache-extension.git

commit 0191a6f73e40ccf6edb9a3ea28299e6325feaae2
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon May 16 20:56:36 2022 +0200

    Fix possible NPE caused by concurrency
---
 .../java/org/apache/maven/buildcache/RemoteCacheRepositoryImpl.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/maven/buildcache/RemoteCacheRepositoryImpl.java b/src/main/java/org/apache/maven/buildcache/RemoteCacheRepositoryImpl.java
index b4664fd..b04e3e8 100644
--- a/src/main/java/org/apache/maven/buildcache/RemoteCacheRepositoryImpl.java
+++ b/src/main/java/org/apache/maven/buildcache/RemoteCacheRepositoryImpl.java
@@ -231,7 +231,7 @@ public class RemoteCacheRepositoryImpl implements RemoteCacheRepository, Closeab
         }
     }
 
-    private final AtomicReference<Optional<CacheReport>> cacheReportSupplier = new AtomicReference<>();
+    private final AtomicReference<CacheReport> cacheReportSupplier = new AtomicReference<>();
 
     @Nonnull
     @Override
@@ -285,7 +285,7 @@ public class RemoteCacheRepositoryImpl implements RemoteCacheRepository, Closeab
 
     private Optional<CacheReport> findCacheInfo()
     {
-        Optional<CacheReport> report = cacheReportSupplier.get();
+        Optional<CacheReport> report = Optional.ofNullable( cacheReportSupplier.get() );
         if ( !report.isPresent() )
         {
             try
@@ -299,7 +299,7 @@ public class RemoteCacheRepositoryImpl implements RemoteCacheRepository, Closeab
                         cacheConfig.getBaselineCacheUrl(), e );
                 report = Optional.empty();
             }
-            cacheReportSupplier.compareAndSet( null, report );
+            cacheReportSupplier.compareAndSet( null, report.orElse( null ) );
         }
         return report;
     }