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 20d6132ec..55c6b587c 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 @@ -45,6 +45,8 @@ public final class NamedLockFactoryAdapter { public static final String TIME_KEY = "aether.syncContext.named.time"; + public static final String EXCLUSIVE_TIME_KEY = "aether.syncContext.named.exclusiveTime"; + public static final long DEFAULT_TIME = 900L; public static final String TIME_UNIT_KEY = "aether.syncContext.named.time.unit"; @@ -111,6 +113,8 @@ private static class AdaptedLockSyncContext implements SyncContext { private final long time; + private final long exclusiveTime; + private final TimeUnit timeUnit; private final int retry; @@ -128,7 +132,8 @@ private AdaptedLockSyncContext( this.shared = shared; this.lockNaming = lockNaming; this.namedLockFactory = namedLockFactory; - this.time = getTime(session); + this.time = getTime(session, DEFAULT_TIME, TIME_KEY); + this.exclusiveTime = getTime(session, DEFAULT_TIME, EXCLUSIVE_TIME_KEY); this.timeUnit = getTimeUnit(session); this.retry = getRetry(session); this.retryWait = getRetryWait(session); @@ -137,6 +142,9 @@ private AdaptedLockSyncContext( if (time < 0L) { throw new IllegalArgumentException(TIME_KEY + " value cannot be negative"); } + if (exclusiveTime < 0L) { + throw new IllegalArgumentException(EXCLUSIVE_TIME_KEY + " value cannot be negative"); + } if (retry < 0L) { throw new IllegalArgumentException(RETRY_KEY + " value cannot be negative"); } @@ -145,8 +153,8 @@ private AdaptedLockSyncContext( } } - private long getTime(final RepositorySystemSession session) { - return ConfigUtils.getLong(session, DEFAULT_TIME, TIME_KEY); + private long getTime(final RepositorySystemSession session, long defaultValue, String... keys) { + return ConfigUtils.getLong(session, defaultValue, keys); } private TimeUnit getTimeUnit(final RepositorySystemSession session) { @@ -168,11 +176,13 @@ public void acquire(Collection artifacts, Collection illegalStateExceptions = new ArrayList<>(); for (int attempt = 1; attempt <= attempts; attempt++) { - LOGGER.trace( - "Attempt {}: Need {} {} lock(s) for {}", attempt, keys.size(), shared ? "read" : "write", keys); + LOGGER.trace("Attempt {}: Need {} {} lock(s) for {}", attempt, keys.size(), lockKindString, keys); int acquiredLockCount = 0; try { if (attempt > 1) { @@ -180,28 +190,24 @@ public void acquire(Collection artifacts, Collection artifacts, Collection config = new HashMap<>(); config.put(NamedLockFactoryAdapter.TIME_KEY, String.valueOf(ADAPTER_TIME)); + config.put(NamedLockFactoryAdapter.EXCLUSIVE_TIME_KEY, String.valueOf(ADAPTER_TIME)); config.put(NamedLockFactoryAdapter.TIME_UNIT_KEY, ADAPTER_TIME_UNIT.name()); when(session.getConfigProperties()).thenReturn(config); }