More defensive type-checks.
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 10 Mar 2015 20:35:20 +0100
changeset 180868c0229e193e
parent 1807 6083160bfccf
child 1809 72a0dbfa2ae8
More defensive type-checks.
launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java
     1.1 --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java	Tue Mar 10 20:18:55 2015 +0100
     1.2 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/CompileCP.java	Tue Mar 10 20:35:20 2015 +0100
     1.3 @@ -18,12 +18,14 @@
     1.4  package org.apidesign.bck2brwsr.launcher;
     1.5  
     1.6  import java.io.File;
     1.7 +import java.io.FileNotFoundException;
     1.8  import java.io.IOException;
     1.9  import java.io.InputStream;
    1.10  import java.io.StringWriter;
    1.11  import java.net.JarURLConnection;
    1.12  import java.net.URISyntaxException;
    1.13  import java.net.URL;
    1.14 +import java.net.URLConnection;
    1.15  import java.util.Set;
    1.16  import java.util.logging.Logger;
    1.17  import org.apidesign.bck2brwsr.aot.Bck2BrwsrJars;
    1.18 @@ -95,8 +97,13 @@
    1.19              if (u == null) {
    1.20                  throw new IOException("Cannot find InterruptedException class on classpath: " + System.getProperty("java.class.path"));
    1.21              }
    1.22 -            JarURLConnection juc = (JarURLConnection)u.openConnection();
    1.23 -            rt = Bck2BrwsrJars.configureFrom(null, new File(juc.getJarFileURL().toURI()));
    1.24 +            final URLConnection conn = u.openConnection();
    1.25 +            if (conn instanceof JarURLConnection) {
    1.26 +                JarURLConnection juc = (JarURLConnection)conn;
    1.27 +                rt = Bck2BrwsrJars.configureFrom(null, new File(juc.getJarFileURL().toURI()));
    1.28 +            } else {
    1.29 +                throw new FileNotFoundException("Not a JAR URL: " + u);
    1.30 +            }
    1.31          } catch (URISyntaxException ex) {
    1.32              throw new IOException(ex);
    1.33          }