jMonkeyEngine / jMonkeyEngine/jmonkeyengine

UrlAssetInfo throw exceptions that can be ignored

Open
#2,000 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
4.3k
Forks
1.2k
Avg merge
4d 7h
Merged PRs (30d)
14

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the UrlAssetInfo class and compare create(...) with openStream(), especially their handling of URLConnection.getInputStream() failures. Check the callers that expect IOException and determine the consistent exception behavior required. Done means URL read failures are handled consistently without callers missing the thrown exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.