| Severity | 2 |
|---|---|
| Enabled | yes |
| Waivable | |
| Configuration |
Allowed maximum item in the throws clause: max-throws: 3 |
| Violation |
public static TooManyThrowsRuleViolationTestCase readIn(final String fName)
throws FileNotFoundException, IOException, ClassNotFoundException,StreamCorruptedException {
InputStream is = new FileInputStream(fName);
ObjectInputStream ois = new ObjectInputStream(is);
TooManyThrowsRuleViolationTestCase obj =
(TooManyThrowsRuleViolationTestCase) ois.readObject();
return obj;
}
|
| Fix |
public static TooManyThrowsRuleFixTestCase readIn(final String fName)throws HammurapiTestCasesException {
TooManyThrowsRuleFixTestCase obj = null;
try {
InputStream is = new FileInputStream(fName);
ObjectInputStream ois = new ObjectInputStream(is);
obj = (TooManyThrowsRuleFixTestCase) ois.readObject();
} catch (FileNotFoundException e) {
logger.error(SERIALIZATION_ERROR + e.getMessage());
throw new HammurapiTestCasesException(e);
} catch (ClassNotFoundException e) {
logger.error(SERIALIZATION_ERROR + e.getMessage());
throw new HammurapiTestCasesException(e);
} catch (StreamCorruptedException e) {
logger.error(SERIALIZATION_ERROR + e.getMessage());
throw new HammurapiTestCasesException(e);
} catch (IOException e) {
logger.error(SERIALIZATION_ERROR + e.getMessage());
throw new HammurapiTestCasesException(e);
}
return obj;
}
|