Details about the known misuse from the MUBench dataset.
Description: | RtcpReceivedEvent.java calls java.lang.long.parseLong without first checking whether the argument parses. This lead to an uncaught NumberFormatException :
Oracle Java 7 API specification.
This pull request adds a check with a more helpful exception message. Kindly let me know if you want me to change the message.
|
Fix Description: |
(see diff) |
Violation Types: |
- missing/exception_handling
|
In File: | org/asteriskjava/manager/event/RtcpReceivedEvent.java |
In Method: | setPt(String) |
Code with Misuse: |
class RtcpReceivedEvent {
public void setPt(String ptString)
{
// Format is "PT: %d(%s)"
if (ptString == null || ptString.length() == 0)
{
this.pt = null;
return;
}
if (ptString.indexOf('(') > 0)
{
this.pt = Long.parseLong(ptString.substring(0, ptString.indexOf('(')));
}
else
{
this.pt = Long.parseLong(ptString);
}
}
}
|
Code with Pattern(s): |
class HandleNotANumber {
long pattern(String s) {
try {
return Long.parseLong(s);
} catch (NumberFormatException e) {
throw new NumberFormatException(String.format("Input string [%s] is not a parseable long", s));
}
}
}
|