Skip to content

Commit

Permalink
dont set knownToExist
Browse files Browse the repository at this point in the history
  • Loading branch information
pstreef committed Sep 23, 2024
1 parent d11969c commit 6694ac9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -779,21 +779,20 @@ MavenRepository normalizeRepository(MavenRepository repository) throws Throwable

ReachabilityResult reachability = reachable(repository, applyAuthenticationToRequest(repository, request));
if (reachability.isSuccess()) {
return repository.withUri(httpsUri).withKnownToExist(true);
return repository.withUri(httpsUri);
}
reachability = reachable(repository, applyAuthenticationToRequest(repository, request.withMethod(HttpSender.Method.HEAD).url(httpsUri)));
if (reachability.isReachable()) {
return repository.withUri(httpsUri).withKnownToExist(reachability.isSuccess());
return repository.withUri(httpsUri);
}

if (!originalUrl.equals(httpsUri)) {
reachability = reachable(repository, applyAuthenticationToRequest(repository, request.withMethod(HttpSender.Method.OPTIONS).url(originalUrl)));
if (reachability.isSuccess()) {
return MavenRepository.from(repository, originalUrl).withKnownToExist(true);
return MavenRepository.from(repository, originalUrl);
}
reachability = reachable(repository, applyAuthenticationToRequest(repository, request.withMethod(HttpSender.Method.HEAD).url(originalUrl)));
if (reachability.isReachable()) {
return MavenRepository.from(repository, originalUrl).withKnownToExist(reachability.isSuccess());
return MavenRepository.from(repository, originalUrl);
}
}
// Won't be null if server is unreachable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,23 +766,22 @@ void connectTimeout() {
}

@CsvSource(textBlock = """
https://repo1.maven.org/maven2/, https://repo1.maven.org/maven2/, true
https://repo1.maven.org/maven2, https://repo1.maven.org/maven2/, true
http://repo1.maven.org/maven2/, https://repo1.maven.org/maven2/, true
https://repo1.maven.org/maven2/, https://repo1.maven.org/maven2/
https://repo1.maven.org/maven2, https://repo1.maven.org/maven2/
http://repo1.maven.org/maven2/, https://repo1.maven.org/maven2/
https://oss.sonatype.org/content/repositories/snapshots/, https://oss.sonatype.org/content/repositories/snapshots/, true
https://artifactory.moderne.ninja/artifactory/moderne-public/, https://artifactory.moderne.ninja/artifactory/moderne-public/, true
https://repo.maven.apache.org/maven2/, https://repo.maven.apache.org/maven2/, true
https://jitpack.io/, https://jitpack.io/, true
https://oss.sonatype.org/content/repositories/snapshots/, https://oss.sonatype.org/content/repositories/snapshots/
https://artifactory.moderne.ninja/artifactory/moderne-public/, https://artifactory.moderne.ninja/artifactory/moderne-public/
https://repo.maven.apache.org/maven2/, https://repo.maven.apache.org/maven2/
https://jitpack.io/, https://jitpack.io/
""")
@ParameterizedTest
void normalizeRepository(String originalUrl, String expectedUrl, boolean knownToExist) throws Throwable {
void normalizeRepository(String originalUrl, String expectedUrl) throws Throwable {
MavenPomDownloader downloader = new MavenPomDownloader(new InMemoryExecutionContext());
MavenRepository repository = new MavenRepository("id", originalUrl, null, null, null, null, null);
MavenRepository normalized = downloader.normalizeRepository(repository);
assertThat(normalized).isNotNull();
assertThat(normalized.getUri()).isEqualTo(expectedUrl);
assertThat(normalized.isKnownToExist()).isEqualTo(knownToExist);
}

private static GroupArtifactVersion createArtifact(Path repository) throws IOException {
Expand Down

0 comments on commit 6694ac9

Please sign in to comment.