gpt4 book ai didi

java - Findbugs 不排除我们的 Java 应用程序中的方法

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:54:38 25 4
gpt4 key购买 nike

我在 findbugs exclude.xml 文件中添加了以下内容

<Match>
<Class name="com.ebay.kernel.service.invocation.SvcInvocationConfig" />
<Method name="getConnectionConfig" />
<Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>

需要忽略的代码

public ConnectionConfig getConnectionConfig() {
return m_connectionConfig;
}

因为 Findbugs 报告说

m_connectionConfig suffers from (inconsistent synchronization) BUG - IS2_INCONSISTENT_SYNC

但出于某种原因,我的 findbugs 并没有被忽略。

当我执行以下操作时 -

<Match>
<Class name="com.ebay.kernel.service.invocation.SvcInvocationConfig" />
<Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>

整个类(class)都忽略了 findbugs,但一旦我介绍

<Method name="getConnectionConfig">

标记在两者之间,findbugs 不再因该方法而被忽略。

谁能帮我弄清楚为什么?

最佳答案

IS2_INCONSISTENT_SYNC警告是在数据成员(字段)上发出的,根据它在各种方法、构造函数、静态 block 等中的用法,而不是在方法本身上,所以你不能用 <Method> 忽略它。元素。

相反,您可以使用 <Field>元素:

<Match>
<Class name="com.ebay.kernel.service.invocation.SvcInvocationConfig" />
<Field name="m_connectionConfig" />
<Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>

关于java - Findbugs 不排除我们的 Java 应用程序中的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27491622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com