jmonkeyengine icon indicating copy to clipboard operation
jmonkeyengine copied to clipboard

UrlAssetInfo throw exceptions that can be ignored

Open drhaozhong opened this issue 3 years ago • 0 comments

UrlAssetInfo has the following code:

public static UrlAssetInfo create(AssetManager assetManager, AssetKey key, URL url) throws IOException { // Check if URL can be reached. This will throw // IOException which calling code will handle. URLConnection conn = url.openConnection(); conn.setUseCaches(false); InputStream in = conn.getInputStream();

    // For some reason url cannot be reached?
    if (in == null){
        return null;
    }else{
        return new UrlAssetInfo(assetManager, key, url, in);
    }
}

The comments say that calling code will catch IOException. The same class does not throw another example for the same error:

@Override public InputStream openStream() { if (in != null){ // Reuse the already existing stream (only once) InputStream in2 = in; in = null; return in2; }else{ // Create a new stream for subsequent invocations. try { URLConnection conn = url.openConnection(); conn.setUseCaches(false); return conn.getInputStream(); } catch (IOException ex) { throw new AssetLoadException("Failed to read URL " + url, ex); } } }

If the calling code catches IOException as expected, it will miss the exception thrown by openStream. Will this problem be fixed?

drhaozhong avatar Apr 27 '23 01:04 drhaozhong