diff --git a/core/src/main/java/hudson/tools/JDKInstaller.java b/core/src/main/java/hudson/tools/JDKInstaller.java index 8945b11124..d8b5efc480 100644 --- a/core/src/main/java/hudson/tools/JDKInstaller.java +++ b/core/src/main/java/hudson/tools/JDKInstaller.java @@ -57,7 +57,6 @@ import java.io.InputStream; import java.net.URL; import java.net.HttpURLConnection; import java.net.URLEncoder; -import java.net.MalformedURLException; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -361,7 +360,7 @@ public class JDKInstaller extends ToolInstaller { } } - private URL locateStage2(TaskListener log, String page) throws MalformedURLException { + private URL locateStage2(TaskListener log, String page) throws IOException { Pattern HREF = Pattern.compile(" that confuses dom4j/jtidy @@ -384,6 +383,10 @@ public class JDKInstaller extends ToolInstaller { LOGGER.fine("Found a download candidate: "+ url); } + if (urls.isEmpty()) { + throw new IOException("found no matches in: " + page); + } + // prefer the first match because sometimes "optional downloads" follow the main bundle return new URL(urls.get(0)); }