Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Findbugs not excluding methods in our java application

Tags:

java

findbugs

I have added the following in the findbugs exclude.xml file

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

The code that needs to be ignored

public ConnectionConfig getConnectionConfig() {
    return m_connectionConfig;
}

because Findbugs reports that

m_connectionConfig suffers from (inconsistent synchronization) BUG - IS2_INCONSISTENT_SYNC

But for some reason my findbugs are not getting ignored.

and when I do following -

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

The findbugs is getting ignored for the entire class but as soon as I introduce

<Method name="getConnectionConfig">

tag in between, findbugs stops getting ignored for that method.

Can someone help me figure out why?

like image 446
P C Avatar asked Dec 15 '14 19:12

P C


1 Answers

The IS2_INCONSISTENT_SYNC warning is issued on a data member (field), according to its usages by various methods, constructors, static blocks, etc. and not on the method itself, so you can't ignore it with a <Method> element.

Instead, you could use a <Field> element:

<Match>
    <Class name="com.ebay.kernel.service.invocation.SvcInvocationConfig" />
    <Field name="m_connectionConfig" />
    <Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match>
like image 62
Mureinik Avatar answered Nov 17 '22 04:11

Mureinik