Details about the known misuse from the MUBench dataset.
Description: | The Rule constructor in org.joda.time.tz.ZoneInfoCompiler.java does not
check the number of elements in the StringTokenizer obtained from parsing
the timezone file. There is an assumption that the input TimeZone file
will always be valid, leading to runtime exceptions with no good error
message when the file is invalid. This pull request adds a potential fix
and a test for this issue. |
Fix Description: |
(see diff) |
Violation Types: |
- missing/condition/value_or_state
|
In File: | org/joda/time/tz/ZoneInfoCompiler.java |
In Method: | Rule(StringTokenizer) |
Code with Misuse: |
class ZoneInfoCompiler.Rule {
Rule(StringTokenizer st) {
iName = st.nextToken().intern();
iFromYear = parseYear(st.nextToken(), 0);
iToYear = parseYear(st.nextToken(), iFromYear);
if (iToYear < iFromYear) {
throw new IllegalArgumentException();
}
iType = parseOptional(st.nextToken());
iDateTimeOfYear = new DateTimeOfYear(st);
iSaveMillis = parseTime(st.nextToken());
iLetterS = parseOptional(st.nextToken());
}
}
|
Code with Pattern(s): |
class TokenizerCount {
String pattern(StringTokenizer st) {
if (st.countTokens() < 1) {
throw new IllegalArgumentException("too few tokens");
}
return st.nextToken();
}
}
|