I've been testing both the rules "Correctness - Possible null pointer dereference" and "Correctness - Possible null pointer dereference in method on exception path" on my sonar instance. Unfortunately, the following code is never detected as wrong
public ResultatsDTO getContent(String userName, String roid) {
ResultatsDTO resultats = null;
try {
resultats = GetDocContentCaller.instance().getDocumentContent(
userName, roid);
} catch (Exception e) {
LOGGER.error(
"Erreur dans l'appel de l'ejb lors du telechargement du document docBaseId"
+ roid, e);
if (resultats.getErrorCode() == 0) {
resultats.setErrorCode(ERROR_CODE_104);
resultats.setMessage("erreur lors de l appel du web service");
}
}
return resultats;
}
Netbeans detects correctly this issue but sonar 3.6.1 doesn't.
Is it normal ? Is it the good rule ?
Thanks for your help
testisn't definitely assigned. - Jon Skeettestin thetryblock. But now the code is completely changed. - Rohit Jain