Thursday, May 8, 2014

Appears to call the same method on the same object redundantly in FindBugs

Issue Here below:

try {
----------
----------
}
catch (final SQLException e) {
LOG.error("Error Message Test: " + e.getMessage());
            throw new YourException(e.getMessage(), e);
}


Solution for that:

try {
--------------
--------------
 } catch (final SQLException e) {
        String errorMessage = e.getMessage();
            LOG.error("Error Message Test: " + errorMessage);
            throw new YourException(errorMessage, e);

3 comments:

  1. If e is an object and we don't know whether the embedded object inside e is null or not.
    In this scenario who to cover it so that we don't get the above error ??

    ReplyDelete