Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve issue #2039 (DOM readIntSavableMap() doesn't check exceptions) #2052

Closed
wants to merge 1 commit into from
Closed

Conversation

tohidemyname
Copy link

Integer.parseInt(currentElem.getAttribute("key")) can throw NumberFormatException, which is inconsistent with other parsing methods.

Integer.parseInt(currentElem.getAttribute("key")) can throw
NumberFormatException, which is inconsistent with other parsing methods.
@stephengold stephengold changed the title Fixing https://github.com/jMonkeyEngine/jmonkeyengine/issues/2039. solve issue #2039 (DOM readIntSavableMap() doesn't check exceptions) Aug 8, 2023
@stephengold stephengold added this to the Future Release milestone Aug 8, 2023
@stephengold stephengold linked an issue Aug 8, 2023 that may be closed by this pull request
ret.put(key, val);
}catch (NumberFormatException nfe) {
IOException io = new IOException(nfe.toString());
io.initCause(nfe);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea to throw a checked exception from an unchecked exception, if you want to propagate an unchecked runtime exception to the user application use a throws NumberFormatException in the method declaration to give a clue to catch the exception or else use a strategy pattern with a compatible JDK interface to handle this exception from the user application, but this shouldn't throw a business checked exception.

@tohidemyname tohidemyname closed this by deleting the head repository Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOMInputCapsule.readIntSavableMap does not check exceptions
3 participants