Empty catch blocks can hide exceptions
94 byte[] decrypted = cipherDecrypt.doFinal(encryptedBytes);
95
96 return new String(decrypted);
97 }catch(Exception e) { 98 99 }100 return null;
101 }
102
Empty catch blocks can hide exceptions
69
70 return DatatypeConverter.printHexBinary(encryptedIVAndText);
71 }
72 catch(Exception e) { 73 74 } 75 return null;
76 }
77
Empty catch blocks can hide exceptions
56 try {
57 jdbcTemplate.update("DELETE from session where sessCookie=?",cookieID);
58 return true;
59 }catch(Exception e) {60 61 }62 return false;
63 }
64 public boolean deleteAllCookie() {
Description
When a catch
clause is empty, it essentially ignores any occurrences of the particular exception it handles. This could allow critical bugs to go undiagnosed because any relevant exceptions indicative of a bug would be discarded within this catch
block.
Bad Practice
try {
// ...
} catch(Exception e) {
// Nothing here
}
Recommended
Consider at least logging the exception to ensure that issues that may actually be bugs are not missed.
try {
// ...
} catch(Exception e) {
System.err.println(e.message); // It may be better to make use of a more robust logging solution like logback.
}
References
- Spotbugs - DE_MIGHT_IGNORE