Details about the known misuse from the MUBench dataset.
| Description: | Open a FileInputStream on a non-existing file throws.
|
| Fix Description: |
Check File.exists() first.
|
| Violation Types: |
- missing/condition/value_or_state
|
| In File: | FISExists.java |
| In Method: | misuse(File) |
| Code with Misuse: |
class FISExists {
public void misuse(File file) throws IOException {
try (FileInputStream fis = new FileInputStream(file)) {
// do something with fis...
}
}
}
|
| Code with Pattern(s): |
public class CheckFileExists {
public void pattern(File file) throws IOException {
if (file.exists()) {
try (FileInputStream fis = new FileInputStream(file)) {
// do something with fis...
}
}
}
}
|