Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
index 7c5872eb0..ac896b2d7 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
@@ -89,15 +89,9 @@ public class DownloadManager {
if (provContext == null)
provContext = new ProvisioningContext(agent);
- IQueryable<IArtifactRepository> repoQueryable = provContext.getArtifactRepositories(subMonitor.newChild(250));
- IQuery<IArtifactRepository> all = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION);
- IArtifactRepository[] repositories = repoQueryable.query(all, subMonitor.newChild(250)).toArray(IArtifactRepository.class);
+ IArtifactRepository[] repositories = getArtifactRepositories(subMonitor);
if (repositories.length == 0)
return new Status(IStatus.ERROR, EngineActivator.ID, Messages.download_no_repository, new Exception(Collect.NO_ARTIFACT_REPOSITORIES_AVAILABLE));
- // Although we get a sorted list back from the ProvisioningContext above, it
- // gets unsorted when we convert the queryable into an array so we must re-sort it.
- // See https://bugs.eclipse.org/335153.
- Arrays.sort(repositories, LOCAL_FIRST_COMPARATOR);
fetch(repositories, subMonitor.newChild(500));
return overallStatus(monitor);
} finally {
@@ -105,6 +99,23 @@ public class DownloadManager {
}
}
+ /**
+ * @return artifact repositories sorted according to LOCAL_FIRST_COMPARATOR
+ */
+ private IArtifactRepository[] getArtifactRepositories(SubMonitor subMonitor) {
+ IQuery<IArtifactRepository> queryArtifactRepositories = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION);
+ IQueryable<IArtifactRepository> artifactRepositories = provContext.getArtifactRepositories(subMonitor.newChild(250));
+ IQueryResult<IArtifactRepository> queryResult = artifactRepositories.query(queryArtifactRepositories, subMonitor.newChild(250));
+ IArtifactRepository[] repositories = queryResult.toArray(IArtifactRepository.class);
+
+ // Although we get a sorted list back from the ProvisioningContext above, it
+ // gets unsorted when we convert the queryable into an array so we must re-sort it.
+ // See https://bugs.eclipse.org/335153.
+ Arrays.sort(repositories, LOCAL_FIRST_COMPARATOR);
+
+ return repositories;
+ }
+
private void fetch(IArtifactRepository[] repositories, IProgressMonitor mon) {
SubMonitor monitor = SubMonitor.convert(mon, requestsToProcess.size());
for (int i = 0; i < repositories.length && !requestsToProcess.isEmpty() && !monitor.isCanceled(); i++) {

Back to the top