diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningContext.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningContext.java index 998a9b3c0..b43cf2ecd 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningContext.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningContext.java @@ -223,18 +223,22 @@ private void getLoadedRepository(URI location, IArtifactRepositoryManager repoMa } private Set getLoadedMetadataRepositories(IProgressMonitor monitor) { - IMetadataRepositoryManager repoManager = agent.getService(IMetadataRepositoryManager.class); - URI[] repositories = metadataRepositories == null ? repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL) : metadataRepositories; - - Map repos = new HashMap<>(); - SubMonitor sub = SubMonitor.convert(monitor, repositories.length); - - // Clear out the list of remembered artifact repositories - referencedArtifactRepositories = new HashMap<>(); - for (URI repositorie : repositories) { - loadMetadataRepository(repoManager, repositorie, repos, shouldFollowReferences(), sub.split(1)); + if (loadedRepos == null) { + IMetadataRepositoryManager repoManager = agent.getService(IMetadataRepositoryManager.class); + URI[] repositories = metadataRepositories == null + ? repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL) + : metadataRepositories; + + loadedRepos = new HashMap<>(); + SubMonitor sub = SubMonitor.convert(monitor, repositories.length); + + // Clear out the list of remembered artifact repositories + referencedArtifactRepositories = new HashMap<>(); + for (URI repositorie : repositories) { + loadMetadataRepository(repoManager, repositorie, loadedRepos, shouldFollowReferences(), sub.split(1)); + } } - return new HashSet<>(repos.values()); + return new HashSet<>(loadedRepos.values()); } private void loadMetadataRepository(IMetadataRepositoryManager manager, URI location, @@ -421,6 +425,7 @@ private > void loadRepository(IRepositoryManager private static final Comparator ARTIFACT_KEY_COMPARATOR = Comparator // .comparing(IArtifactKey::getId) // .thenComparing(IArtifactKey::getVersion); + private Map loadedRepos; /** * Returns a map from simple artifact repository location to a subset of the