|
22 | 22 | import java.util.Collection; |
23 | 23 | import java.util.Deque; |
24 | 24 | import java.util.concurrent.TimeUnit; |
| 25 | +import java.util.stream.Collectors; |
25 | 26 |
|
26 | 27 | import org.eclipse.aether.ConfigurationProperties; |
27 | 28 | import org.eclipse.aether.RepositorySystemSession; |
|
33 | 34 | import org.eclipse.aether.named.NamedLockKey; |
34 | 35 | import org.eclipse.aether.named.providers.FileLockNamedLockFactory; |
35 | 36 | import org.eclipse.aether.util.ConfigUtils; |
| 37 | +import org.eclipse.aether.util.artifact.ArtifactIdUtils; |
36 | 38 | import org.slf4j.Logger; |
37 | 39 | import org.slf4j.LoggerFactory; |
38 | 40 |
|
@@ -255,14 +257,48 @@ public void acquire(Collection<? extends Artifact> artifacts, Collection<? exten |
255 | 257 | } |
256 | 258 | // if we are here, means all attempts were unsuccessful: fail |
257 | 259 | close(); |
258 | | - FailedToAcquireLockException ex = new FailedToAcquireLockException( |
259 | | - shared, |
260 | | - "Could not acquire " + lockKind + " lock for " |
261 | | - + namedLock.key().resources() + " using lock " |
262 | | - + namedLock.key().name() + " in " + timeStr); |
| 260 | + String message = "Could not acquire " + lockKind + " lock for " |
| 261 | + + lockSubjects(artifacts, metadatas) + " in " + timeStr |
| 262 | + + "; consider using '" + CONFIG_PROP_TIME |
| 263 | + + "' property to increase lock timeout to a value that fits your environment"; |
| 264 | + FailedToAcquireLockException ex = new FailedToAcquireLockException(shared, message); |
263 | 265 | throw namedLockFactory.onFailure(ex); |
264 | 266 | } |
265 | 267 |
|
| 268 | + private String lockSubjects( |
| 269 | + Collection<? extends Artifact> artifacts, Collection<? extends Metadata> metadatas) { |
| 270 | + StringBuilder builder = new StringBuilder(); |
| 271 | + if (artifacts != null && !artifacts.isEmpty()) { |
| 272 | + builder.append("artifacts: ") |
| 273 | + .append(artifacts.stream().map(ArtifactIdUtils::toId).collect(Collectors.joining(", "))); |
| 274 | + } |
| 275 | + if (metadatas != null && !metadatas.isEmpty()) { |
| 276 | + if (builder.length() != 0) { |
| 277 | + builder.append("; "); |
| 278 | + } |
| 279 | + builder.append("metadata: ") |
| 280 | + .append(metadatas.stream().map(this::metadataSubjects).collect(Collectors.joining(", "))); |
| 281 | + } |
| 282 | + return builder.toString(); |
| 283 | + } |
| 284 | + |
| 285 | + private String metadataSubjects(Metadata metadata) { |
| 286 | + String name = ""; |
| 287 | + if (!metadata.getGroupId().isEmpty()) { |
| 288 | + name += metadata.getGroupId(); |
| 289 | + if (!metadata.getArtifactId().isEmpty()) { |
| 290 | + name += ":" + metadata.getArtifactId(); |
| 291 | + if (!metadata.getVersion().isEmpty()) { |
| 292 | + name += ":" + metadata.getVersion(); |
| 293 | + } |
| 294 | + } |
| 295 | + } |
| 296 | + if (!metadata.getType().isEmpty()) { |
| 297 | + name += (name.isEmpty() ? "" : ":") + metadata.getType(); |
| 298 | + } |
| 299 | + return name; |
| 300 | + } |
| 301 | + |
266 | 302 | @Override |
267 | 303 | public void close() { |
268 | 304 | while (!locks.isEmpty()) { |
|
0 commit comments