Skip to content

Commit

Permalink
Only report unrecovered repositoryAccessFailed (#4037)
Browse files Browse the repository at this point in the history
* Only report unrecovered repositoryAccessFailed

Following questions like openrewrite/rewrite-maven-plugin#742

* Add trailing slash known to trip up some repositories
  • Loading branch information
timtebeek authored Feb 23, 2024
1 parent 3a69b22 commit 4a73816
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,9 @@ public MavenRepository normalizeRepository(MavenRepository originalRepository, M
String httpsUri = repository.getUri().toLowerCase().startsWith("http:") ?
repository.getUri().replaceFirst("[hH][tT][tT][pP]://", "https://") :
repository.getUri();
if (!httpsUri.endsWith("/")) {
httpsUri += "/";
}

HttpSender.Request.Builder request = applyAuthenticationToRequest(repository, httpSender.get(httpsUri));
MavenRepository normalized = null;
Expand All @@ -744,11 +747,6 @@ public MavenRepository normalizeRepository(MavenRepository originalRepository, M
if (e.isServerReached()) {
normalized = repository.withUri(httpsUri);
}
if (!"Directory listing forbidden".equals(e.getBody())) {
ctx.getResolutionListener().repositoryAccessFailed(httpsUri, t);
}
} else {
ctx.getResolutionListener().repositoryAccessFailed(httpsUri, t);
}
if (normalized == null) {
if (!httpsUri.equals(originalUrl)) {
Expand Down Expand Up @@ -776,11 +774,11 @@ public MavenRepository normalizeRepository(MavenRepository originalRepository, M
}
} catch (Throwable e) {
// ok to fall through here and cache a null
ctx.getResolutionListener().repositoryAccessFailed(originalUrl, t);
}
}
}
if (normalized == null) {
if (normalized == null && !(t instanceof HttpSenderResponseException &&
((HttpSenderResponseException) t).getBody().contains("Directory listing forbidden"))) {
ctx.getResolutionListener().repositoryAccessFailed(repository.getUri(), t);
}
}
Expand Down

0 comments on commit 4a73816

Please sign in to comment.