logo       

Maven Report finds bugs Eclipse Plugin does not: msg#00043

java.findbugs.general

Subject: Maven Report finds bugs Eclipse Plugin does not


I'm new to Findbugs and I'm trying to integrate it in both our build and our
IDEs. We use Maven2 for our builds, so I added the findbugs-maven-plugin
and got a report. In that report, it indicated a spot in one of our classes
where we might be failing to close an open stream. Wanting to fix it, I
installed the Findbugs Eclipse plugin and ran that and it failed to flag the
code. So basically, the Eclipse and Maven plugins appear to be out of sync.
I think I have them both set to the same level of warning and "effort", and
the Open Stream bug is enabled in the Eclipse plugin.

My suspicion is that the Maven plugin is using an older version of FindBugs.
The code snippet that fails is this:

public static void copyFile(File source, File destination) throws
IOException
{
// Create channel on the source
FileChannel srcChannel = new FileInputStream(source).getChannel();

// Create channel on the destination
FileChannel dstChannel = new
FileOutputStream(destination).getChannel();

// Copy file contents from source to destination
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());

// Close the channels
srcChannel.close();
dstChannel.close();
}

I'm not an expert on NIO, but maybe it's safe to open those channels outside
of a try/finally block to ensure they get closed. Could the newer version
of Findbugs be aware of this?

Can anyone shed any light?

K.C.

P.s. Here's my configuration from the Maven2 Plugin site:

<reporting>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<configuration>
<threshold>Normal</threshold>
<effort>Default</effort>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
<includeFilterFile>findbugs-include.xml</includeFilterFile>
<visitors>FindDeadLocalStores,UnreadFields</visitors>
<omitVisitors>FindDeadLocalStores,UnreadFields</omitVisitors>
<pluginList>/libs/fb-contrib/fb-contrib-2.8.0.jar</pluginList>
</configuration>
</plugin>
...
</reporting>
--
View this message in context:
http://www.nabble.com/Maven-Report-finds-bugs-Eclipse-Plugin-does-not-tf2432032.html#a6781511
Sent from the findbugs-discuss mailing list archive at Nabble.com.



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise