Skip to content

Commit

Permalink
address sonarqube issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gsergiu committed Nov 30, 2022
1 parent 86d93df commit fe30fd0
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
public abstract class AbstractExceptionHandlingController extends ApiResponseBuilder {

Logger LOG = LogManager.getLogger(getClass());
Logger logger = LogManager.getLogger(getClass());

final static Map<Class<? extends Exception>, HttpStatus> statusCodeMap = new HashMap<Class<? extends Exception>, HttpStatus>();
//see DefaultHandlerExceptionResolver.doResolveException
Expand Down Expand Up @@ -83,7 +83,7 @@ public ResponseEntity<String> handleException(Exception ex, HttpServletRequest r
ApiResponse res = getErrorReport(req.getParameter(CommonApiConstants.PARAM_WSKEY), req.getServletPath(),
ex, includeErrorStack);
// for runtime exception, log the stacktrace
LOG.error("respond with internal server error for runtime exception:", ex);
logger.error("respond with internal server error for runtime exception:", ex);
return buildErrorResponse(res, HttpStatus.INTERNAL_SERVER_ERROR);
}

Expand All @@ -102,7 +102,7 @@ public ResponseEntity<String> handleMissingRequestParamException(Exception ex, H
ex, includeErrorStack);

// for NestedRuntime exception, and known servlet/spring exceptions log the stacktrace as well
LOG.error("respond with internal server error for runtime exception:", ex);
logger.error("respond with internal server error for runtime exception:", ex);
return buildErrorResponse(res, statusCode);
}

Expand All @@ -123,9 +123,10 @@ protected MultiValueMap<String, String> buildHeadersMap() {
}

private void logTraceOrErrorMessage(HttpStatus status, Exception ex, String message) {
if (status.value() >= 500) {
LOG.error(message, ex);
int INTERNAL_SERVER_ERROR = 500;
if (status.value() >= INTERNAL_SERVER_ERROR) {
logger.error(message, ex);
}
LOG.error(message, ex.getMessage());
logger.error(message, ex.getMessage());
}
}

0 comments on commit fe30fd0

Please sign in to comment.