[rfc][icedtea-web] do not dye if jnlp's icons points to nothing (eg 404)

Jie Kang jkang at redhat.com
Mon Feb 2 14:12:47 UTC 2015



----- Original Message -----
> This patch is fixing state, when icon is expected to be downlaoded, but its
> location do not exists.
> Then when this code expect it to be found, NPE is thrown.
> 
> Hmm.. Looking to this after break,
> 
> - location = CacheUtil.getCachedResource(uiconLocation, null,
> UpdatePolicy.SESSION)
> -                     .toString();
> + locationURL = CacheUtil.getCachedResource(uiconLocation, null,
> UpdatePolicy.SESSION);
> + if (locationURL == null) {return null;}
> + location = locationURL.toString();

I don't think this works without some more changes:

CacheUtil.getCachedResource(URL location, ...) {
[...]
        try {
            File f = rt.getCacheFile(location);
            // TODO: Should be toURI().toURL()
            return f.toURL();
        } catch (MalformedURLException ex) {
            return location;
        }
}

Even though rt.getCacheFile(...) returns null if the file wasn't downloaded, this function will return f.toURL() or the original url, location.

This behavior is kind of weird as users of this function can't easily tell if it was successful or not. And looking at rt.getCacheFile(...), for input with 'file' protocol, it might actually result in f.toURL() == location, which means you can't assume it failed if it returns the url 'location'.

Maybe we should change this from returning the original url on MalformedURLException to returning null instead? 

> 
> Is probably much more suitable (need to test it)

> 
> 
> J.
> 

-- 

Jie Kang

OpenJDK Team - Software Engineering Intern


More information about the distro-pkg-dev mailing list