Skip to content

Commit

Permalink
Instead of storing the mirror ids, the new getMirrors method is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevloral committed Jan 7, 2024
1 parent b1a693f commit 48c008c
Showing 1 changed file with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
Expand All @@ -40,11 +41,6 @@ public class DefaultRepositoryIdManager implements IRepositoryIdManager {

private Map<URI, String> knownMavenRepositoryIds = new ConcurrentHashMap<>();

/**
* Map of known mirror identifiers, indexed by their URI.
*/
private Map<URI, String> knownMavenMirrorIds = new ConcurrentHashMap<>();

@Override
public void addMapping(String mavenRepositoryId, URI location) {
if (mavenRepositoryId == null)
Expand All @@ -57,15 +53,6 @@ public void addMapping(String mavenRepositoryId, URI location) {
logger.warn("p2 repository with URL " + key + " is associated with multiple IDs; was '" + previousValue
+ "', now is '" + mavenRepositoryId + "'");
}

// Checks if a mirror exists for the given location
MavenRepositoryLocation repositoryLocation = new MavenRepositoryLocation(mavenRepositoryId, key);
MavenRepositoryLocation mirrorLocation = settings.getMirror(repositoryLocation);
if (mirrorLocation != null) {
// A mirror exists. Adds its id to the map of known mirror ids.
URI mirrorKey = normalize(mirrorLocation.getURL());
knownMavenMirrorIds.put(mirrorKey, mirrorLocation.getId());
}
}

private static URI normalize(URI location) {
Expand Down Expand Up @@ -132,9 +119,11 @@ private static boolean certainlyNoRemoteURL(URI location) {

@Override
public Stream<MavenRepositoryLocation> getKnownMavenRepositoryLocations() {
return Stream.concat(knownMavenRepositoryIds.entrySet().stream(), knownMavenMirrorIds.entrySet().stream())
.map(e -> new MavenRepositoryLocation(e.getValue(), e.getKey()));
}
// Returns both repository and mirror locations
return Stream.concat(
knownMavenRepositoryIds.entrySet().stream().map(e -> new MavenRepositoryLocation(e.getValue(), e.getKey())),
StreamSupport.stream(settings.getMirrors().spliterator(), false));
}

@Override
public MavenRepositorySettings getSettings() {
Expand Down

0 comments on commit 48c008c

Please sign in to comment.