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

                  声纳不应该再打扰你了

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

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

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                    <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>