<small id='bgBE6'></small><noframes id='bgBE6'>

      <legend id='bgBE6'><style id='bgBE6'><dir id='bgBE6'><q id='bgBE6'></q></dir></style></legend>

      <i id='bgBE6'><tr id='bgBE6'><dt id='bgBE6'><q id='bgBE6'><span id='bgBE6'><b id='bgBE6'><form id='bgBE6'><ins id='bgBE6'></ins><ul id='bgBE6'></ul><sub id='bgBE6'></sub></form><legend id='bgBE6'></legend><bdo id='bgBE6'><pre id='bgBE6'><center id='bgBE6'></center></pre></bdo></b><th id='bgBE6'></th></span></q></dt></tr></i><div id='bgBE6'><tfoot id='bgBE6'></tfoot><dl id='bgBE6'><fieldset id='bgBE6'></fieldset></dl></div>
      <tfoot id='bgBE6'></tfoot>
        • <bdo id='bgBE6'></bdo><ul id='bgBE6'></ul>

        声纳抱怨记录并重新抛出异常

        Sonar complaining about logging and rethrowing the exception(声纳抱怨记录并重新抛出异常)

          <tfoot id='Ast1H'></tfoot>

          <legend id='Ast1H'><style id='Ast1H'><dir id='Ast1H'><q id='Ast1H'></q></dir></style></legend>

          1. <i id='Ast1H'><tr id='Ast1H'><dt id='Ast1H'><q id='Ast1H'><span id='Ast1H'><b id='Ast1H'><form id='Ast1H'><ins id='Ast1H'></ins><ul id='Ast1H'></ul><sub id='Ast1H'></sub></form><legend id='Ast1H'></legend><bdo id='Ast1H'><pre id='Ast1H'><center id='Ast1H'></center></pre></bdo></b><th id='Ast1H'></th></span></q></dt></tr></i><div id='Ast1H'><tfoot id='Ast1H'></tfoot><dl id='Ast1H'><fieldset id='Ast1H'></fieldset></dl></div>
              • <bdo id='Ast1H'></bdo><ul id='Ast1H'></ul>
                  <tbody id='Ast1H'></tbody>
              • <small id='Ast1H'></small><noframes id='Ast1H'>

                  本文介绍了声纳抱怨记录并重新抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的程序中有以下代码,在将其与 Maven 集成后,我正在运行 SonarQube 5 以对其进行代码质量检查.

                  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.

                  但是,Sonar 抱怨我应该记录或重新抛出此异常.

                  However, Sonar is complaining that I should Either log or rethrow this exception.

                  我在这里缺少什么?我还没有记录异常吗?

                  What am I missing here? Am I not already logging the exception?

                   private boolean authenticate(User user) {
                          boolean validUser = false;
                          int validUserCount = 0;
                          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());
                              LOG.error(sqle.getMessage());
                          }
                          if (validUserCount == 1) {
                              validUser = true;
                          }
                          return validUser;
                      }
                  

                  推荐答案

                  你应该这样做:

                  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);
                  }
                  

                  声纳不应该再打扰你了

                  这篇关于声纳抱怨记录并重新抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Slf4j LoggerFactory.getLogger and sonarqube(Slf4j LoggerFactory.getLogger 和 sonarqube)
                  Security - Array is stored directly(安全性 - 数组直接存储)
                  SonarQube quot;Class Not Foundquot; during Main AST Scan(SonarQube“找不到类在主 AST 扫描期间)
                  Integrate Spock#39;s test with Sonar(将 Spock 的测试与声纳集成)
                  How do I make Hudson/Jenkins fail if Sonar thresholds are breached?(如果违反声纳阈值,我如何让 Hudson/Jenkins 失败?)
                  automatically add curly brackets to all if/else/for/while etc. in a java code-base(自动将大括号添加到 java 代码库中的所有 if/else/for/while 等)
                    <tbody id='k70Fz'></tbody>

                      <small id='k70Fz'></small><noframes id='k70Fz'>

                    1. <i id='k70Fz'><tr id='k70Fz'><dt id='k70Fz'><q id='k70Fz'><span id='k70Fz'><b id='k70Fz'><form id='k70Fz'><ins id='k70Fz'></ins><ul id='k70Fz'></ul><sub id='k70Fz'></sub></form><legend id='k70Fz'></legend><bdo id='k70Fz'><pre id='k70Fz'><center id='k70Fz'></center></pre></bdo></b><th id='k70Fz'></th></span></q></dt></tr></i><div id='k70Fz'><tfoot id='k70Fz'></tfoot><dl id='k70Fz'><fieldset id='k70Fz'></fieldset></dl></div>
                    2. <legend id='k70Fz'><style id='k70Fz'><dir id='k70Fz'><q id='k70Fz'></q></dir></style></legend>

                          • <bdo id='k70Fz'></bdo><ul id='k70Fz'></ul>
                            <tfoot id='k70Fz'></tfoot>