Details about the known misuse from the MUBench dataset.
Description: | Should catch NoSuchElementException around SortedMap.firstKey()
|
Fix Description: |
(see diff) |
Violation Types: |
- missing/exception handling
|
In File: | org/apache/lucene/index/ParallelReader.java |
In Method: | ParallelTermEnum() |
Code with Misuse: |
class ParallelReader.ParallelTermEnum {
public ParallelTermEnum() throws IOException {
field = (String)fieldToReader.firstKey();
if (field != null)
termEnum = ((IndexReader)fieldToReader.get(field)).terms();
}
}
|
Code with Pattern(s): |
class HandleNoFirstKey {
void pattern(SortedMap fieldToReader) {
String field;
try {
field = (String) fieldToReader.firstKey();
} catch(NoSuchElementException e) {
return;
}
if (field != null) {
// do something with field...
}
}
}
|