This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
The following commit(s) were added to refs/heads/master by this push:
new b7a5b41 [MRESOLVER-227] Refactor NamedLockFactorySelector to a
managed component
b7a5b41 is described below
commit b7a5b411d994d2f7093358299184a87d8328f51d
Author: Tamas Cservenak <[email protected]>
AuthorDate: Tue Nov 23 15:20:55 2021 +0100
[MRESOLVER-227] Refactor NamedLockFactorySelector to a managed component
This closes #135
---
.../eclipse/aether/impl/DefaultServiceLocator.java | 5 +-
.../eclipse/aether/impl/guice/AetherModule.java | 5 +-
.../synccontext/DefaultSyncContextFactory.java | 9 +-
.../synccontext/named/NamedLockFactoryAdapter.java | 55 +++++----
...kFactory.java => NamedLockFactorySelector.java} | 21 ++--
.../named/SimpleNamedLockFactorySelector.java | 137 +++++++++++++++++++++
.../NamedLockFactoryAdapterTestSupport.java | 45 ++++++-
.../NamedLockFactoryAdapterTestSupport.java | 7 +-
8 files changed, 236 insertions(+), 48 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..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
@@ -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;
@@ -53,9 +54,7 @@ public final class DefaultSyncContextFactory
{
this.namedLockFactoryAdapter = new NamedLockFactoryAdapter(
selector.getSelectedNameMapper(),
- selector.getSelectedNamedLockFactory(),
- NamedLockFactorySelector.TIME,
- NamedLockFactorySelector.TIME_UNIT
+ selector.getSelectedNamedLockFactory()
);
}
@@ -71,9 +70,7 @@ public final class DefaultSyncContextFactory
locator.getService( NamedLockFactorySelector.class ) );
this.namedLockFactoryAdapter = new NamedLockFactoryAdapter(
selector.getSelectedNameMapper(),
- selector.getSelectedNamedLockFactory(),
- NamedLockFactorySelector.TIME,
- NamedLockFactorySelector.TIME_UNIT
+ 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 6fb68d3..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()
@@ -80,8 +78,6 @@ public final class NamedLockFactoryAdapter
private final NameMapper lockNaming;
- private final SessionAwareNamedLockFactory
sessionAwareNamedLockFactory;
-
private final NamedLockFactory namedLockFactory;
private final long time;
@@ -91,18 +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.sessionAwareNamedLockFactory = namedLockFactory instanceof
SessionAwareNamedLockFactory
- ? (SessionAwareNamedLockFactory) namedLockFactory : null;
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
@@ -118,8 +128,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 58%
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..653d39b 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,21 @@ 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;
/**
- * 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 selected {@link NamedLockFactory}, never null.
*/
- NamedLock getLock( RepositorySystemSession session, String name );
+ NamedLockFactory getSelectedNamedLockFactory();
+
+ /**
+ * Returns the selected {@link NameMapper}, never null.
+ */
+ 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..db91308
--- /dev/null
+++
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/SimpleNamedLockFactorySelector.java
@@ -0,0 +1,137 @@
+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;
+
+/**
+ * Simple selector implementation that uses Java system properties and sane
default values.
+ */
+@Singleton
+@Named
+public final class SimpleNamedLockFactorySelector
+ implements NamedLockFactorySelector
+{
+ public static final String FACTORY_KEY =
"aether.syncContext.named.factory";
+
+ public static final String NAME_MAPPER_KEY =
"aether.syncContext.named.nameMapper";
+
+ 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,
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 );
+ }
+
+ /**
+ * 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,
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, getNameMapperName() );
+ }
+
+ /**
+ * 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 NamedLockFactory selectNamedLockFactory( final Map<String,
NamedLockFactory> factories,
+ final String factoryName )
+ {
+ NamedLockFactory factory = factories.get( factoryName );
+ if ( factory == null )
+ {
+ throw new IllegalArgumentException( "Unknown NamedLockFactory
name: " + factoryName
+ + ", known ones: " + factories.keySet() );
+ }
+ return factory;
+ }
+
+ private NameMapper selectNameMapper( final Map<String, NameMapper>
nameMappers,
+ final String mapperName )
+ {
+ NameMapper nameMapper = nameMappers.get( mapperName );
+ if ( nameMapper == null )
+ {
+ 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