- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
引用规则的描述(SonarQube 4.5.5):
// Noncompliant - exception is lost (only message is preserved)
try { /* ... */ }
catch (Exception e) { LOGGER.info(e.getMessage()); }
通过向记录器提供异常类,堆栈跟踪将写入日志。
我们代码库中的问题是这样的:通过关注Tell, don't ask原则上,我们使用检查异常作为正常执行路径的一部分,我们不希望它们导致不合理的大日志消息。
几个例子:服务器响应错误代码,数据库语句执行失败乐观锁定(并发用户)......
我的建议:将这个案例一分为二。
// Noncompliant - exception is lost (only message is preserved)
try { /* ... */ }
catch (Exception e) { LOGGER.info(e.getMessage()); }
和
// Compliant - exception is lost (only message is preserved) but there is business logic handling the situation
try {
/* ... */
} catch (Exception e) {
LOGGER.info(e.getMessage());
*/ exception handling */
}
规则 squid:S00108(代码块不能为空)不会捕获问题,因为存在日志语句。
这不合理吗?我错过了什么重要的事情吗?
注意:我重写了问题以阐明我的用例
最佳答案
我理解维护堆栈跟踪和所有这些的论点,但我认为它会使您的日志因 < ERROR 级别的事件而膨胀。一种解决方案是将消息记录为 WARN,并将异常对象记录为 DEBUG 或 TRACE。这样,普通用户日志配置就不会像往常一样被堆栈跟踪淹没,但如果需要,仍然可以获得堆栈跟踪。
关于java - 为什么鱿鱼:S1166 not accept exception messages only when logging caught exceptions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33032194/
我想在 squid 3.2.3 中拒绝所有以 iso 开头的 URL 所以,我放入了 squid.conf: acl torrent_sites dstdom_regex -i iso acl
我在 squid 代理服务器后面遇到 Maven 问题。 我的系统有一个模块依赖于与远程网络服务的外部通信。 我在 ~/.m2/settings.xml 下有我的 maven 代理配置,但显然,这些信
这是我的设置: SonarQube 5.6.6 SonarJava 插件 4.8.0.9441 代码: public class BaseActivity extends android.app.Ac
在我们的代码库中,我们得到 Sonar 报告违反规则 squid:S2095 的代码如下: PreparedStatement ps = null; try { ps
我正在一个有很多图像的网站上工作(想想smugmug/flickr),从我读到的内容来看,flickr正在使用鱿鱼作为图像缓存。我的图像将存储在Amazon S3上,因此缓存服务器也将有助于节省托管资
我正在尝试通过squid.conf将请求从Squid重定向到我的应用程序(用C编写): http_port 3128 # some default configuration out of the b
使用方法返回 Connection 是一种常见的做法,例如在 Hikari 的 HikariConnectionProvider 中 public Connection getConnection()
根据定义, "Magic number" is a value that should be given a symbolic name, but was instead slipped into t
今天基本上开始使用 Squid 和 iptables(google 是你的 friend )。这东西会要了我的命。 我在 Ubuntu 9.04 服务器上将 Squid3 设置为透明代理。当我使用代理
S2583:如何更改条件 ps != null 使其不总是计算为“false”? PreparedStatement ps = null; if (ps != null) { try {
大家好, 我在 Squid-Proxy 中设置两个输出互联网。下面是“图”我想要得到的最终结果: SERVER1: SQUID SERVER SERVER2: Internet2 :: Client
简而言之,我正在寻找一种简单的方法来执行以下操作 (如果可能,请提供代码示例): 在我的电脑上设置并启动一个代理服务器(比如地址是 10.10.200.200:6767),它可以从我的手机中捕获所有网
我想知道是否有人能够帮助我解决鱿鱼问题。我正在尝试在 ubuntu 16.04 上设置 squid。我使用 apt-get install 来安装它。我有 3.5 版。 我似乎无法让 https 端正
我在 Spring Tool Suite 中使用 Sonarlint V3.5.0。当我在代码中有默认构造函数时,我收到 squid:S1186 警告,如下所示: public class TestC
当这些包中的类之间存在使用或导入类型的依赖时,包之间就存在循环。 考虑以下示例。假设有 4 个类:Truck 和 org.example.car 包中的接口(interface) Car 以及 Nav
我正在尝试安装squid 3.5.4(在docker上,运行debian 8)并以ssl-bump模式运行它。编译: ./configure --prefix=/opt/squid --srcdir=
我是一名优秀的程序员,十分优秀!