jMonkeyEngine / jMonkeyEngine/jmonkeyengine
SAXUtil throws inconsistent exceptions when it encounters wrong formats
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 14
Description
SAXUtil throws SAXException when formats are wrong. For example, a method is as follows:
public static int parseInt(String i, int def) throws SAXException{
if (i == null)
return def;
else{
try {
return Integer.parseInt(i);
} catch (NumberFormatException ex){
throw new SAXException("Expected an integer, got '"+i+"'");
}
}
}
The other classes throw IOException. For example, DOMInputCapsule.java has the following code:
public int readInt(String name, int defVal) throws IOException {
String tmpString = currentElem.getAttribute(name);
if (tmpString == null || tmpString.length() < 1) return defVal;
try {
return Integer.parseInt(tmpString);
} catch (NumberFormatException nfe) {
IOException io = new IOException(nfe.toString());
io.initCause(nfe);
throw io;
} catch (DOMException de) {
IOException io = new IOException(de.toString());
io.initCause(de);
throw io;
}
}
I assume that all wrong formats will throw IOException. As a result, my code fails to catch the exceptions thrown by SAXException.
Can jmonkeyengine fix the problem?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with SAXUtil.parseInt and DOMInputCapsule.readInt, then inspect the related format-parsing methods and their callers. Decide and apply a consistent exception contract for invalid formats, and verify that affected callers can catch the documented 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
- 35/100