diff options
author | Karsten Thoms | 2017-11-29 05:27:54 +0000 |
---|---|---|
committer | Karsten Thoms | 2018-04-09 12:09:32 +0000 |
commit | caf0ccfd33f9ac75d2a9fafbdc4e2d98e53bc19b (patch) | |
tree | 7ee0b8cf39b3534c749fbd29e0760ce80a987b32 /bundles/org.eclipse.equinox.p2.engine | |
parent | 930fe11bdde0f9796ae3e888695f01c4558169b6 (diff) | |
download | rt.equinox.p2-caf0ccfd33f9ac75d2a9fafbdc4e2d98e53bc19b.tar.gz rt.equinox.p2-caf0ccfd33f9ac75d2a9fafbdc4e2d98e53bc19b.tar.xz rt.equinox.p2-caf0ccfd33f9ac75d2a9fafbdc4e2d98e53bc19b.zip |
Bug 527874 - Remember failed repositories on load requestI20180412-2000
When a loading a repository failed once, its location is remembered to
early exit on subsequent load requests. Multiple requests can happen
e.g. during Check for Updates action.
Change-Id: I56258d50523d95dff84ef4153bfc687f3bf80355
Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.engine')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningContext.java | 61 |
1 files changed, 41 insertions, 20 deletions
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 f9ab50bfb..feb99ff00 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 @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation * WindRiver - https://bugs.eclipse.org/bugs/show_bug.cgi?id=227372 * Sonatype, Inc. - ongoing development + * Karsten Thoms - Bug#527874 *******************************************************************************/ package org.eclipse.equinox.p2.engine; @@ -39,6 +40,10 @@ public class ProvisioningContext { private URI[] metadataRepositories; //metadata repositories to consult private final Map<String, String> properties = new HashMap<>(); private Map<String, URI> referencedArtifactRepositories = null; + private Map<URI, IArtifactRepository> loadedArtifactRepositories = new HashMap<>(); + private Map<URI, IMetadataRepository> loadedMetadataRepositories = new HashMap<>(); + private Set<URI> failedArtifactRepositories = new HashSet<>(); + private Set<URI> failedMetadataRepositories = new HashSet<>(); private static final String FILE_PROTOCOL = "file"; //$NON-NLS-1$ @@ -156,15 +161,8 @@ public class ProvisioningContext { List<IArtifactRepository> repos = new ArrayList<>(); SubMonitor sub = SubMonitor.convert(monitor, (repositories.length + 1) * 100); for (int i = 0; i < repositories.length; i++) { - if (sub.isCanceled()) { - throw new OperationCanceledException(); - } URI location = repositories[i]; - try { - repos.add(repoManager.loadRepository(location, sub.newChild(100))); - } catch (ProvisionException e) { - //skip unreadable repositories - } + getLoadedRepository(location, repoManager, repos, sub); // Remove this URI from the list of extra references if it is there. if (referencedArtifactRepositories != null && location != null) { referencedArtifactRepositories.remove(location.toString()); @@ -174,16 +172,32 @@ public class ProvisioningContext { if (referencedArtifactRepositories != null && referencedArtifactRepositories.size() > 0 && shouldFollowArtifactReferences()) { SubMonitor innerSub = SubMonitor.convert(sub.newChild(100), referencedArtifactRepositories.size() * 100); for (URI referencedURI : referencedArtifactRepositories.values()) { - try { - repos.add(repoManager.loadRepository(referencedURI, innerSub.newChild(100))); - } catch (ProvisionException e) { - // skip unreadable repositories - } + getLoadedRepository(referencedURI, repoManager, repos, innerSub); } } return repos; } + private void getLoadedRepository(URI location, IArtifactRepositoryManager repoManager, List<IArtifactRepository> repos, SubMonitor monitor) { + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + if (failedArtifactRepositories.contains(location)) { + return; + } + try { + IArtifactRepository repository = loadedArtifactRepositories.get(location); + if (repository == null) { + repository = repoManager.loadRepository(location, monitor.newChild(100)); + loadedArtifactRepositories.put(location, repository); + } + repos.add(repository); + } catch (ProvisionException e) { + //skip and remember unreadable repositories + failedArtifactRepositories.add(location); + } + } + private Set<IMetadataRepository> getLoadedMetadataRepositories(IProgressMonitor monitor) { IMetadataRepositoryManager repoManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME); URI[] repositories = metadataRepositories == null ? repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL) : metadataRepositories; @@ -204,19 +218,26 @@ public class ProvisioningContext { } private void loadMetadataRepository(IMetadataRepositoryManager manager, URI location, HashMap<String, IMetadataRepository> repos, boolean followMetadataRepoReferences, IProgressMonitor monitor) { + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } // if we've already processed this repo, don't do it again. This keeps us from getting // caught up in circular references. - if (repos.containsKey(location.toString())) + if (repos.containsKey(location.toString()) || failedMetadataRepositories.contains(location)) { return; + } SubMonitor sub = SubMonitor.convert(monitor, 1000); // First load the repository itself. - IMetadataRepository repository; - try { - repository = manager.loadRepository(location, sub.newChild(500)); - } catch (ProvisionException e) { - // nothing more to do - return; + IMetadataRepository repository = loadedMetadataRepositories.get(location); + if (repository == null) { + try { + repository = manager.loadRepository(location, sub.newChild(500)); + loadedMetadataRepositories.put(location, repository); + } catch (ProvisionException e) { + failedMetadataRepositories.add(location); + return; + } } repos.put(location.toString(), repository); Collection<IRepositoryReference> references = repository.getReferences(); |