Sonar complaining about logging and rethrowing the exception

前端 未结 4 1065
闹比i
闹比i 2020-12-06 04:32

I have the following piece of code in my program and I am running SonarQube 5 for code quality check on it after integrating it with Maven.

However, Sonar is complai

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 05:18

    You should do it this way :

    try {
        DataSource dataSource = (DataSource) getServletContext().getAttribute("dataSource");
        validUserCount = new MasterDao(dataSource).getValidUserCount(user);
    } catch (SQLException sqle) {
        LOG.error("Exception while validating user credentials for user with username: " +
                user.getUsername() + " and pwd:" + user.getPwd(), sqle);
    }
    

    Sonar shouldn't bother you anymore

提交回复
热议问题