You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2021/11/23 14:26:01 UTC

[maven-resolver] branch selectors created (now b38d606)

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

cstamas pushed a change to branch selectors
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git.


      at b38d606  Apply time source change

This branch includes the following new commits:

     new 5f1043d  Refactory selectors
     new b38d606  Apply time source change

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.


[maven-resolver] 01/02: Refactory selectors

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

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

commit 5f1043d52b7c67fa391618fa16c6aef8d15f8e86
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Tue Nov 23 15:20:55 2021 +0100

    Refactory selectors
    
    Split the static helper class and make it a component.
---
 .../eclipse/aether/impl/DefaultServiceLocator.java |   5 +-
 .../eclipse/aether/impl/guice/AetherModule.java    |   5 +-
 .../synccontext/DefaultSyncContextFactory.java     |   9 +-
 .../synccontext/named/NamedLockFactoryAdapter.java |   7 +-
 ...kFactory.java => NamedLockFactorySelector.java} |  33 +++--
 .../named/SimpleNamedLockFactorySelector.java      | 142 +++++++++++++++++++++
 6 files changed, 176 insertions(+), 25 deletions(-)

diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java
index b706bfa..037f302 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/DefaultServiceLocator.java
@@ -55,7 +55,8 @@ import org.eclipse.aether.internal.impl.Maven2RepositoryLayoutFactory;
 import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
 import org.eclipse.aether.internal.impl.slf4j.Slf4jLoggerFactory;
 import org.eclipse.aether.internal.impl.synccontext.DefaultSyncContextFactory;
-import org.eclipse.aether.internal.impl.synccontext.NamedLockFactorySelector;
+import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactorySelector;
+import org.eclipse.aether.internal.impl.synccontext.named.SimpleNamedLockFactorySelector;
 import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider;
 import org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory;
 import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider;
@@ -222,7 +223,7 @@ public final class DefaultServiceLocator
         addService( LocalRepositoryManagerFactory.class, EnhancedLocalRepositoryManagerFactory.class );
         addService( LoggerFactory.class, Slf4jLoggerFactory.class );
         addService( TrackingFileManager.class, DefaultTrackingFileManager.class );
-        addService( NamedLockFactorySelector.class, NamedLockFactorySelector.class );
+        addService( NamedLockFactorySelector.class, SimpleNamedLockFactorySelector.class );
     }
 
     private <T> Entry<T> getEntry( Class<T> type, boolean create )
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java
index 1fe9db2..4681982 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/guice/AetherModule.java
@@ -43,7 +43,8 @@ import org.eclipse.aether.impl.RepositoryEventDispatcher;
 import org.eclipse.aether.internal.impl.DefaultTrackingFileManager;
 import org.eclipse.aether.internal.impl.TrackingFileManager;
 import org.eclipse.aether.internal.impl.synccontext.DefaultSyncContextFactory;
-import org.eclipse.aether.internal.impl.synccontext.NamedLockFactorySelector;
+import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactorySelector;
+import org.eclipse.aether.internal.impl.synccontext.named.SimpleNamedLockFactorySelector;
 import org.eclipse.aether.internal.impl.synccontext.named.GAVNameMapper;
 import org.eclipse.aether.internal.impl.synccontext.named.DiscriminatingNameMapper;
 import org.eclipse.aether.internal.impl.synccontext.named.NameMapper;
@@ -158,7 +159,7 @@ public class AetherModule
         .to( EnhancedLocalRepositoryManagerFactory.class ).in( Singleton.class );
         bind( TrackingFileManager.class ).to( DefaultTrackingFileManager.class ).in( Singleton.class );
 
-        bind( NamedLockFactorySelector.class ).in( Singleton.class );
+        bind( NamedLockFactorySelector.class ).to( SimpleNamedLockFactorySelector.class ).in( Singleton.class );
         bind( SyncContextFactory.class ).to( DefaultSyncContextFactory.class ).in( Singleton.class );
         bind( org.eclipse.aether.impl.SyncContextFactory.class )
                 .to( org.eclipse.aether.internal.impl.synccontext.legacy.DefaultSyncContextFactory.class )
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/DefaultSyncContextFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/DefaultSyncContextFactory.java
index 733f25c..304dcf4 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/DefaultSyncContextFactory.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/DefaultSyncContextFactory.java
@@ -29,6 +29,7 @@ import javax.inject.Singleton;
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.SyncContext;
 import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapter;
+import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactorySelector;
 import org.eclipse.aether.spi.locator.Service;
 import org.eclipse.aether.spi.locator.ServiceLocator;
 import org.eclipse.aether.spi.synccontext.SyncContextFactory;
@@ -54,8 +55,8 @@ public final class DefaultSyncContextFactory
         this.namedLockFactoryAdapter = new NamedLockFactoryAdapter(
             selector.getSelectedNameMapper(),
             selector.getSelectedNamedLockFactory(),
-            NamedLockFactorySelector.TIME,
-            NamedLockFactorySelector.TIME_UNIT
+            selector.waitTime(),
+            selector.waitTimeUnit()
         );
     }
 
@@ -72,8 +73,8 @@ public final class DefaultSyncContextFactory
         this.namedLockFactoryAdapter = new NamedLockFactoryAdapter(
             selector.getSelectedNameMapper(),
             selector.getSelectedNamedLockFactory(),
-            NamedLockFactorySelector.TIME,
-            NamedLockFactorySelector.TIME_UNIT
+            selector.waitTime(),
+            selector.waitTimeUnit()
         );
     }
 
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java
index 6fb68d3..1468278 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java
@@ -80,8 +80,6 @@ public final class NamedLockFactoryAdapter
 
         private final NameMapper lockNaming;
 
-        private final SessionAwareNamedLockFactory sessionAwareNamedLockFactory;
-
         private final NamedLockFactory namedLockFactory;
 
         private final long time;
@@ -97,8 +95,6 @@ public final class NamedLockFactoryAdapter
             this.session = session;
             this.shared = shared;
             this.lockNaming = lockNaming;
-            this.sessionAwareNamedLockFactory = namedLockFactory instanceof SessionAwareNamedLockFactory
-                    ? (SessionAwareNamedLockFactory) namedLockFactory : null;
             this.namedLockFactory = namedLockFactory;
             this.time = time;
             this.timeUnit = timeUnit;
@@ -118,8 +114,7 @@ public final class NamedLockFactoryAdapter
             int acquiredLockCount = 0;
             for ( String key : keys )
             {
-                NamedLock namedLock = sessionAwareNamedLockFactory != null ? sessionAwareNamedLockFactory
-                        .getLock( session, key ) : namedLockFactory.getLock( key );
+                NamedLock namedLock = namedLockFactory.getLock( key );
                 try
                 {
                      LOGGER.trace( "Acquiring {} lock for '{}'",
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SessionAwareNamedLockFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactorySelector.java
similarity index 54%
rename from maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SessionAwareNamedLockFactory.java
rename to maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactorySelector.java
index 28d7961..aa31de8 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SessionAwareNamedLockFactory.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactorySelector.java
@@ -19,22 +19,33 @@ package org.eclipse.aether.internal.impl.synccontext.named;
  * under the License.
  */
 
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.named.NamedLock;
 import org.eclipse.aether.named.NamedLockFactory;
 
+import java.util.concurrent.TimeUnit;
+
 /**
- * A {@link NamedLockFactory} that wants to make use of {@link RepositorySystemSession}.
+ * Selector for {@link NamedLockFactory} and {@link NameMapper} that selects and exposes selected ones. Essentially
+ * all the named locks configuration is here. Implementations may use different strategies to perform selection.
  */
-public interface SessionAwareNamedLockFactory extends NamedLockFactory
+public interface NamedLockFactorySelector
 {
     /**
-     * Creates or reuses existing {@link NamedLock}. Returns instance MUST BE treated as "resource", best in
-     * try-with-resource block.
-     *
-     * @param session the repository system session, must not be {@code null}
-     * @param name    the lock name, must not be {@code null}
-     * @return named  the lock instance, never {@code null}
+     * Returns the value of wait time, how much a lock blocks, must be greater than 0.
+     */
+    long waitTime();
+
+    /**
+     * Returns the time unit of {@link #waitTime()} value, never null.
+     */
+    TimeUnit waitTimeUnit();
+
+    /**
+     * Returns the selected {@link NamedLockFactory}, never null.
+     */
+    NamedLockFactory getSelectedNamedLockFactory();
+
+    /**
+     * Returns the selected {@link NameMapper}, never null.
      */
-    NamedLock getLock( RepositorySystemSession session, String name );
+    NameMapper getSelectedNameMapper();
 }
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SimpleNamedLockFactorySelector.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SimpleNamedLockFactorySelector.java
new file mode 100644
index 0000000..a3d5751
--- /dev/null
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SimpleNamedLockFactorySelector.java
@@ -0,0 +1,142 @@
+package org.eclipse.aether.internal.impl.synccontext.named;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.named.NamedLockFactory;
+import org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory;
+import org.eclipse.aether.named.providers.LocalSemaphoreNamedLockFactory;
+import org.eclipse.aether.named.providers.NoopNamedLockFactory;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Simple selector implementation that uses Java system properties and sane default values.
+ */
+@Singleton
+@Named
+public final class SimpleNamedLockFactorySelector
+    implements NamedLockFactorySelector
+{
+    private static final long TIME = Long.getLong(
+        "aether.syncContext.named.time", 30L
+    );
+
+    private static final TimeUnit TIME_UNIT = TimeUnit.valueOf( System.getProperty(
+        "aether.syncContext.named.time.unit", TimeUnit.SECONDS.name()
+    ) );
+
+    private static final String FACTORY_NAME = System.getProperty(
+        "aether.syncContext.named.factory", LocalReadWriteLockNamedLockFactory.NAME
+    );
+
+    private static final String NAME_MAPPER_NAME = System.getProperty(
+        "aether.syncContext.named.nameMapper", GAVNameMapper.NAME
+    );
+
+    private final NamedLockFactory namedLockFactory;
+
+    private final NameMapper nameMapper;
+
+    /**
+     * Constructor used with DI, where factories are injected and selected based on key.
+     */
+    @Inject
+    public SimpleNamedLockFactorySelector( final Map<String, NamedLockFactory> factories,
+                                           final Map<String, NameMapper> nameMappers )
+    {
+        this.namedLockFactory = selectNamedLockFactory( factories );
+        this.nameMapper = selectNameMapper( nameMappers );
+    }
+
+    /**
+     * Default constructor for ServiceLocator.
+     */
+    public SimpleNamedLockFactorySelector()
+    {
+        Map<String, NamedLockFactory> factories = new HashMap<>();
+        factories.put( NoopNamedLockFactory.NAME, new NoopNamedLockFactory() );
+        factories.put( LocalReadWriteLockNamedLockFactory.NAME, new LocalReadWriteLockNamedLockFactory() );
+        factories.put( LocalSemaphoreNamedLockFactory.NAME, new LocalSemaphoreNamedLockFactory() );
+        this.namedLockFactory = selectNamedLockFactory( factories );
+
+        Map<String, NameMapper> nameMappers = new HashMap<>();
+        nameMappers.put( StaticNameMapper.NAME, new StaticNameMapper() );
+        nameMappers.put( GAVNameMapper.NAME, new GAVNameMapper() );
+        nameMappers.put( DiscriminatingNameMapper.NAME, new DiscriminatingNameMapper( new GAVNameMapper() ) );
+        this.nameMapper = selectNameMapper( nameMappers );
+    }
+
+    @Override
+    public long waitTime()
+    {
+        return TIME;
+    }
+
+    @Override
+    public TimeUnit waitTimeUnit()
+    {
+        return TIME_UNIT;
+    }
+
+    /**
+     * Returns the selected {@link NamedLockFactory}, never null.
+     */
+    @Override
+    public NamedLockFactory getSelectedNamedLockFactory()
+    {
+        return namedLockFactory;
+    }
+
+    /**
+     * Returns the selected {@link NameMapper}, never null.
+     */
+    @Override
+    public NameMapper getSelectedNameMapper()
+    {
+        return nameMapper;
+    }
+
+    private static NamedLockFactory selectNamedLockFactory( final Map<String, NamedLockFactory> factories )
+    {
+        NamedLockFactory factory = factories.get( FACTORY_NAME );
+        if ( factory == null )
+        {
+            throw new IllegalArgumentException( "Unknown NamedLockFactory name: " + FACTORY_NAME
+                + ", known ones: " + factories.keySet() );
+        }
+        return factory;
+    }
+
+    private static NameMapper selectNameMapper( final Map<String, NameMapper> nameMappers )
+    {
+        NameMapper nameMapper = nameMappers.get( NAME_MAPPER_NAME );
+        if ( nameMapper == null )
+        {
+            throw new IllegalArgumentException( "Unknown NameMapper name: " + NAME_MAPPER_NAME
+                + ", known ones: " + nameMappers.keySet() );
+        }
+        return nameMapper;
+    }
+}

[maven-resolver] 02/02: Apply time source change

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

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

commit b38d606892654a69b9de4b39e2abfe7452e3a055
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Tue Nov 23 15:25:42 2021 +0100

    Apply time source change
---
 .../synccontext/DefaultSyncContextFactory.java     |  8 +--
 .../synccontext/named/NamedLockFactoryAdapter.java | 48 +++++++++------
 .../named/NamedLockFactorySelector.java            | 12 ----
 .../named/SimpleNamedLockFactorySelector.java      | 69 ++++++++++------------
 .../NamedLockFactoryAdapterTestSupport.java        | 45 +++++++++++++-
 .../NamedLockFactoryAdapterTestSupport.java        |  7 ++-
 6 files changed, 113 insertions(+), 76 deletions(-)

diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/DefaultSyncContextFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/DefaultSyncContextFactory.java
index 304dcf4..b488cb4 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/DefaultSyncContextFactory.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/DefaultSyncContextFactory.java
@@ -54,9 +54,7 @@ public final class DefaultSyncContextFactory
     {
         this.namedLockFactoryAdapter = new NamedLockFactoryAdapter(
             selector.getSelectedNameMapper(),
-            selector.getSelectedNamedLockFactory(),
-            selector.waitTime(),
-            selector.waitTimeUnit()
+            selector.getSelectedNamedLockFactory()
         );
     }
 
@@ -72,9 +70,7 @@ public final class DefaultSyncContextFactory
             locator.getService( NamedLockFactorySelector.class ) );
         this.namedLockFactoryAdapter = new NamedLockFactoryAdapter(
             selector.getSelectedNameMapper(),
-            selector.getSelectedNamedLockFactory(),
-            selector.waitTime(),
-            selector.waitTimeUnit()
+            selector.getSelectedNamedLockFactory()
         );
     }
 
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java
index 1468278..be9ea1e 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java
@@ -25,6 +25,7 @@ import org.eclipse.aether.artifact.Artifact;
 import org.eclipse.aether.metadata.Metadata;
 import org.eclipse.aether.named.NamedLock;
 import org.eclipse.aether.named.NamedLockFactory;
+import org.eclipse.aether.util.ConfigUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,30 +40,27 @@ import java.util.concurrent.TimeUnit;
  */
 public final class NamedLockFactoryAdapter
 {
-    private final NameMapper nameMapper;
+    public static final String TIME_KEY = "aether.syncContext.named.time";
 
-    private final NamedLockFactory namedLockFactory;
+    public static final long DEFAULT_TIME = 30L;
 
-    private final long time;
+    public static final String TIME_UNIT_KEY = "aether.syncContext.named.time.unit";
 
-    private final TimeUnit timeUnit;
+    public static final TimeUnit DEFAULT_TIME_UNIT = TimeUnit.SECONDS;
 
-    public NamedLockFactoryAdapter( final NameMapper nameMapper, final NamedLockFactory namedLockFactory,
-                                    final long time, final TimeUnit timeUnit )
+    private final NameMapper nameMapper;
+
+    private final NamedLockFactory namedLockFactory;
+
+    public NamedLockFactoryAdapter( final NameMapper nameMapper, final NamedLockFactory namedLockFactory )
     {
         this.nameMapper = Objects.requireNonNull( nameMapper );
         this.namedLockFactory = Objects.requireNonNull( namedLockFactory );
-        if ( time < 0L )
-        {
-            throw new IllegalArgumentException( "time cannot be negative" );
-        }
-        this.time = time;
-        this.timeUnit = Objects.requireNonNull( timeUnit );
     }
 
     public SyncContext newInstance( final RepositorySystemSession session, final boolean shared )
     {
-        return new AdaptedLockSyncContext( session, shared, nameMapper, namedLockFactory, time, timeUnit );
+        return new AdaptedLockSyncContext( session, shared, nameMapper, namedLockFactory );
     }
 
     public void shutdown()
@@ -89,16 +87,32 @@ public final class NamedLockFactoryAdapter
         private final Deque<NamedLock> locks;
 
         private AdaptedLockSyncContext( final RepositorySystemSession session, final boolean shared,
-                                        final NameMapper lockNaming, final NamedLockFactory namedLockFactory,
-                                        final long time, final TimeUnit timeUnit )
+                                        final NameMapper lockNaming, final NamedLockFactory namedLockFactory )
         {
             this.session = session;
             this.shared = shared;
             this.lockNaming = lockNaming;
             this.namedLockFactory = namedLockFactory;
-            this.time = time;
-            this.timeUnit = timeUnit;
+            this.time = getTime( session );
+            this.timeUnit = getTimeUnit( session );
             this.locks = new ArrayDeque<>();
+
+            if ( time < 0L )
+            {
+                throw new IllegalArgumentException( "time cannot be negative" );
+            }
+        }
+
+        private long getTime( final RepositorySystemSession session )
+        {
+            return ConfigUtils.getLong( session, DEFAULT_TIME, TIME_KEY );
+        }
+
+        private TimeUnit getTimeUnit( final RepositorySystemSession session )
+        {
+            return TimeUnit.valueOf( ConfigUtils.getString(
+                session, DEFAULT_TIME_UNIT.name(), TIME_UNIT_KEY
+            ) );
         }
 
         @Override
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactorySelector.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactorySelector.java
index aa31de8..653d39b 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactorySelector.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactorySelector.java
@@ -21,8 +21,6 @@ package org.eclipse.aether.internal.impl.synccontext.named;
 
 import org.eclipse.aether.named.NamedLockFactory;
 
-import java.util.concurrent.TimeUnit;
-
 /**
  * Selector for {@link NamedLockFactory} and {@link NameMapper} that selects and exposes selected ones. Essentially
  * all the named locks configuration is here. Implementations may use different strategies to perform selection.
@@ -30,16 +28,6 @@ import java.util.concurrent.TimeUnit;
 public interface NamedLockFactorySelector
 {
     /**
-     * Returns the value of wait time, how much a lock blocks, must be greater than 0.
-     */
-    long waitTime();
-
-    /**
-     * Returns the time unit of {@link #waitTime()} value, never null.
-     */
-    TimeUnit waitTimeUnit();
-
-    /**
      * Returns the selected {@link NamedLockFactory}, never null.
      */
     NamedLockFactory getSelectedNamedLockFactory();
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SimpleNamedLockFactorySelector.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SimpleNamedLockFactorySelector.java
index a3d5751..db91308 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SimpleNamedLockFactorySelector.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SimpleNamedLockFactorySelector.java
@@ -29,7 +29,6 @@ import javax.inject.Named;
 import javax.inject.Singleton;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Simple selector implementation that uses Java system properties and sane default values.
@@ -39,21 +38,9 @@ import java.util.concurrent.TimeUnit;
 public final class SimpleNamedLockFactorySelector
     implements NamedLockFactorySelector
 {
-    private static final long TIME = Long.getLong(
-        "aether.syncContext.named.time", 30L
-    );
+    public static final String FACTORY_KEY = "aether.syncContext.named.factory";
 
-    private static final TimeUnit TIME_UNIT = TimeUnit.valueOf( System.getProperty(
-        "aether.syncContext.named.time.unit", TimeUnit.SECONDS.name()
-    ) );
-
-    private static final String FACTORY_NAME = System.getProperty(
-        "aether.syncContext.named.factory", LocalReadWriteLockNamedLockFactory.NAME
-    );
-
-    private static final String NAME_MAPPER_NAME = System.getProperty(
-        "aether.syncContext.named.nameMapper", GAVNameMapper.NAME
-    );
+    public static final String NAME_MAPPER_KEY = "aether.syncContext.named.nameMapper";
 
     private final NamedLockFactory namedLockFactory;
 
@@ -66,8 +53,26 @@ public final class SimpleNamedLockFactorySelector
     public SimpleNamedLockFactorySelector( final Map<String, NamedLockFactory> factories,
                                            final Map<String, NameMapper> nameMappers )
     {
-        this.namedLockFactory = selectNamedLockFactory( factories );
-        this.nameMapper = selectNameMapper( nameMappers );
+        this.namedLockFactory = selectNamedLockFactory( factories, getFactoryName() );
+        this.nameMapper = selectNameMapper( nameMappers, getNameMapperName() );
+    }
+
+    /**
+     * Returns selected factory name (or sane default) using System property value of {@link #FACTORY_KEY} and defaults
+     * to {@link LocalReadWriteLockNamedLockFactory#NAME}.
+     */
+    private String getFactoryName()
+    {
+        return System.getProperty( FACTORY_KEY, LocalReadWriteLockNamedLockFactory.NAME );
+    }
+
+    /**
+     * Returns selected name mapper name (or sane default) using System property value of {@link #NAME_MAPPER_KEY} and
+     * defaults to {@link GAVNameMapper#NAME}.
+     */
+    private String getNameMapperName()
+    {
+        return System.getProperty( NAME_MAPPER_KEY, GAVNameMapper.NAME );
     }
 
     /**
@@ -79,25 +84,13 @@ public final class SimpleNamedLockFactorySelector
         factories.put( NoopNamedLockFactory.NAME, new NoopNamedLockFactory() );
         factories.put( LocalReadWriteLockNamedLockFactory.NAME, new LocalReadWriteLockNamedLockFactory() );
         factories.put( LocalSemaphoreNamedLockFactory.NAME, new LocalSemaphoreNamedLockFactory() );
-        this.namedLockFactory = selectNamedLockFactory( factories );
+        this.namedLockFactory = selectNamedLockFactory( factories, getFactoryName() );
 
         Map<String, NameMapper> nameMappers = new HashMap<>();
         nameMappers.put( StaticNameMapper.NAME, new StaticNameMapper() );
         nameMappers.put( GAVNameMapper.NAME, new GAVNameMapper() );
         nameMappers.put( DiscriminatingNameMapper.NAME, new DiscriminatingNameMapper( new GAVNameMapper() ) );
-        this.nameMapper = selectNameMapper( nameMappers );
-    }
-
-    @Override
-    public long waitTime()
-    {
-        return TIME;
-    }
-
-    @Override
-    public TimeUnit waitTimeUnit()
-    {
-        return TIME_UNIT;
+        this.nameMapper = selectNameMapper( nameMappers, getNameMapperName() );
     }
 
     /**
@@ -118,23 +111,25 @@ public final class SimpleNamedLockFactorySelector
         return nameMapper;
     }
 
-    private static NamedLockFactory selectNamedLockFactory( final Map<String, NamedLockFactory> factories )
+    private NamedLockFactory selectNamedLockFactory( final Map<String, NamedLockFactory> factories,
+                                                     final String factoryName )
     {
-        NamedLockFactory factory = factories.get( FACTORY_NAME );
+        NamedLockFactory factory = factories.get( factoryName );
         if ( factory == null )
         {
-            throw new IllegalArgumentException( "Unknown NamedLockFactory name: " + FACTORY_NAME
+            throw new IllegalArgumentException( "Unknown NamedLockFactory name: " + factoryName
                 + ", known ones: " + factories.keySet() );
         }
         return factory;
     }
 
-    private static NameMapper selectNameMapper( final Map<String, NameMapper> nameMappers )
+    private NameMapper selectNameMapper( final Map<String, NameMapper> nameMappers,
+                                         final String mapperName )
     {
-        NameMapper nameMapper = nameMappers.get( NAME_MAPPER_NAME );
+        NameMapper nameMapper = nameMappers.get( mapperName );
         if ( nameMapper == null )
         {
-            throw new IllegalArgumentException( "Unknown NameMapper name: " + NAME_MAPPER_NAME
+            throw new IllegalArgumentException( "Unknown NameMapper name: " + mapperName
                 + ", known ones: " + nameMappers.keySet() );
         }
         return nameMapper;
diff --git a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/synccontext/NamedLockFactoryAdapterTestSupport.java b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/synccontext/NamedLockFactoryAdapterTestSupport.java
index 87cab6f..ce176a7 100644
--- a/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/synccontext/NamedLockFactoryAdapterTestSupport.java
+++ b/maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/synccontext/NamedLockFactoryAdapterTestSupport.java
@@ -35,18 +35,22 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Objects;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 /**
  * UT support for {@link SyncContextFactory}.
  */
-public abstract class NamedLockFactoryAdapterTestSupport {
-    private static final long ADAPTER_TIME = 100L;
+public abstract class NamedLockFactoryAdapterTestSupport
+{
+    private static final long ADAPTER_TIME = 1000L;
 
     private static final TimeUnit ADAPTER_TIME_UNIT = TimeUnit.MILLISECONDS;
 
@@ -67,7 +71,7 @@ public abstract class NamedLockFactoryAdapterTestSupport {
 
     public static void createAdapter() {
         Objects.requireNonNull(namedLockFactory, "NamedLockFactory not set");
-        adapter = new NamedLockFactoryAdapter(nameMapper, namedLockFactory, ADAPTER_TIME, ADAPTER_TIME_UNIT);
+        adapter = new NamedLockFactoryAdapter(nameMapper, namedLockFactory);
     }
 
     @AfterClass
@@ -83,6 +87,10 @@ public abstract class NamedLockFactoryAdapterTestSupport {
         LocalRepository localRepository = new LocalRepository(Files.createTempDirectory("test").toFile());
         session = mock(RepositorySystemSession.class);
         when(session.getLocalRepository()).thenReturn(localRepository);
+        HashMap<String, Object> config = new HashMap<>();
+        config.put(NamedLockFactoryAdapter.TIME_KEY, String.valueOf(ADAPTER_TIME));
+        config.put(NamedLockFactoryAdapter.TIME_UNIT_KEY, ADAPTER_TIME_UNIT.name());
+        when(session.getConfigProperties()).thenReturn(config);
     }
 
     @Test
@@ -202,6 +210,37 @@ public abstract class NamedLockFactoryAdapterTestSupport {
         losers.await();
     }
 
+    @Test
+    public void fullyConsumeLockTime() throws InterruptedException {
+        long start = System.nanoTime();
+        CountDownLatch winners = new CountDownLatch(1); // we expect 1 winner
+        CountDownLatch losers = new CountDownLatch(1); // we expect 1 loser
+        Thread t1 = new Thread(new Access(false, winners, losers, adapter, session, null));
+        Thread t2 = new Thread(new Access(false, winners, losers, adapter, session, null));
+        t1.start();
+        t2.start();
+        t1.join();
+        t2.join();
+        winners.await();
+        losers.await();
+        long end = System.nanoTime();
+        long duration = end - start;
+        long expectedDuration = ADAPTER_TIME_UNIT.toNanos(ADAPTER_TIME);
+        assertThat(duration, greaterThanOrEqualTo(expectedDuration)); // equal in ideal case
+    }
+
+    @Test
+    public void releasedExclusiveAllowAccess() throws InterruptedException {
+        CountDownLatch winners = new CountDownLatch(2); // we expect 1 winner
+        CountDownLatch losers = new CountDownLatch(0); // we expect 1 loser
+        Thread t1 = new Thread(new Access(false, winners, losers, adapter, session, null));
+        new Access(false, winners, losers, adapter, session, null).run();
+        t1.start();
+        t1.join();
+        winners.await();
+        losers.await();
+    }
+
     private static class Access implements Runnable {
         final boolean shared;
         final CountDownLatch winner;
diff --git a/maven-resolver-named-locks-hazelcast/src/test/java/org/eclipse/aether/named/hazelcast/NamedLockFactoryAdapterTestSupport.java b/maven-resolver-named-locks-hazelcast/src/test/java/org/eclipse/aether/named/hazelcast/NamedLockFactoryAdapterTestSupport.java
index 7fc8241..fc85955 100644
--- a/maven-resolver-named-locks-hazelcast/src/test/java/org/eclipse/aether/named/hazelcast/NamedLockFactoryAdapterTestSupport.java
+++ b/maven-resolver-named-locks-hazelcast/src/test/java/org/eclipse/aether/named/hazelcast/NamedLockFactoryAdapterTestSupport.java
@@ -37,6 +37,7 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -62,7 +63,7 @@ public abstract class NamedLockFactoryAdapterTestSupport
 
   protected static void setNamedLockFactory(final NamedLockFactory namedLockFactory) {
     adapter = new NamedLockFactoryAdapter(
-            new DiscriminatingNameMapper(new GAVNameMapper()), namedLockFactory, ADAPTER_TIME, ADAPTER_TIME_UNIT
+            new DiscriminatingNameMapper(new GAVNameMapper()), namedLockFactory
     );
   }
 
@@ -79,6 +80,10 @@ public abstract class NamedLockFactoryAdapterTestSupport
     LocalRepository localRepository = new LocalRepository(Files.createTempDirectory("test").toFile());
     session = mock(RepositorySystemSession.class);
     when(session.getLocalRepository()).thenReturn(localRepository);
+    HashMap<String, Object> config = new HashMap<>();
+    config.put(NamedLockFactoryAdapter.TIME_KEY, String.valueOf(ADAPTER_TIME));
+    config.put(NamedLockFactoryAdapter.TIME_UNIT_KEY, ADAPTER_TIME_UNIT.name());
+    when(session.getConfigProperties()).thenReturn(config);
   }
 
   @Test