Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorSelector.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorSelector.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorSelector.java
index df950174e..1b5599861 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorSelector.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorSelector.java
@@ -256,17 +256,7 @@ public class MirrorSelector {
Document document = getMirrorsDocument(mirrorsURL, monitor);
if (document == null)
return null;
- NodeList mirrorNodes = document.getElementsByTagName("mirror"); //$NON-NLS-1$
- int mirrorCount = mirrorNodes.getLength();
- MirrorInfo[] infos = new MirrorInfo[mirrorCount + 1];
- for (int i = 0; i < mirrorCount; i++) {
- Element mirrorNode = (Element) mirrorNodes.item(i);
- String infoURL = mirrorNode.getAttribute("url"); //$NON-NLS-1$
- infos[i] = new MirrorInfo(infoURL, i);
- }
- //p2: add the base site as the last resort mirror so we can track download speed and failure rate
- infos[mirrorCount] = new MirrorInfo(baseURI.toString(), mirrorCount);
- return infos;
+ return buildMirrorInfos(document);
} catch (Exception e) {
// log if absolute url
if (mirrorsURL != null && (mirrorsURL.startsWith("http://") //$NON-NLS-1$
@@ -279,6 +269,20 @@ public class MirrorSelector {
}
}
+ private MirrorInfo[] buildMirrorInfos(Document document) {
+ NodeList mirrorNodes = document.getElementsByTagName("mirror"); //$NON-NLS-1$
+ int mirrorCount = mirrorNodes.getLength();
+ MirrorInfo[] infos = new MirrorInfo[mirrorCount + 1];
+ for (int i = 0; i < mirrorCount; i++) {
+ Element mirrorNode = (Element) mirrorNodes.item(i);
+ String infoURL = mirrorNode.getAttribute("url"); //$NON-NLS-1$
+ infos[i] = new MirrorInfo(infoURL, i);
+ }
+ //p2: add the base site as the last resort mirror so we can track download speed and failure rate
+ infos[mirrorCount] = new MirrorInfo(baseURI.toString(), mirrorCount);
+ return infos;
+ }
+
private Document getMirrorsDocument(String mirrorsURL, IProgressMonitor monitor) throws ParserConfigurationException, FileNotFoundException, CoreException, AuthenticationFailedException, URISyntaxException, SAXException, IOException {
DocumentBuilderFactory domFactory = SecureXMLUtil.newSecureDocumentBuilderFactory();
DocumentBuilder builder = domFactory.newDocumentBuilder();

Back to the top