gnodet commented on code in PR #1662:
URL: https://github.com/apache/maven-resolver/pull/1662#discussion_r2533669026
##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapter.java:
##########
@@ -216,12 +218,49 @@ public void acquire(Collection<? extends Artifact>
artifacts, Collection<? exten
}
}
if (!illegalStateExceptions.isEmpty()) {
- IllegalStateException ex = new IllegalStateException("Could
not acquire lock(s)");
+ String message = "Could not acquire " + (shared ? "read" :
"write") + " lock for "
+ + lockSubjects(artifacts, metadatas) + " in " + time +
" " + timeUnit;
+ if (shared) {
+ message += "; consider using '" + TIME_KEY
+ + "' property to increase lock timeout to a value
that fits your environment";
+ }
+ FailedToAcquireLockException ex = new
FailedToAcquireLockException(shared, message);
illegalStateExceptions.forEach(ex::addSuppressed);
throw namedLockFactory.onFailure(ex);
}
}
+ private String lockSubjects(
+ Collection<? extends Artifact> artifacts, Collection<? extends
Metadata> metadatas) {
+ StringBuilder builder = new StringBuilder();
+ if (artifacts != null && !artifacts.isEmpty()) {
+ builder.append("artifacts: ")
+
.append(artifacts.stream().map(ArtifactIdUtils::toId).collect(Collectors.joining(",
")));
+ }
+ if (metadatas != null && !metadatas.isEmpty()) {
+ if (builder.length() != 0) {
+ builder.append("; ");
+ }
+ builder.append("metadata: ")
+
.append(metadatas.stream().map(this::metadataSubjects).collect(Collectors.joining(",
")));
+ }
+ return builder.toString();
+ }
+
+ private String metadataSubjects(Metadata metadata) {
+ String name = "";
+ if (!metadata.getGroupId().isEmpty()) {
+ name += metadata.getGroupId();
+ if (!metadata.getArtifactId().isEmpty()) {
+ name += "." + metadata.getArtifactId();
Review Comment:
`.` or `:` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]