findbugs

When using the DelayQueue of Java, should I implement equals() and hashCode() as well?

时间秒杀一切 提交于 2019-12-13 00:10:41
问题 I'm currently dealing with a class that's using a DelayQueue . I've noticed that since the objects in the DelayQueue implement the Delayed interface, the said objects need to implement a compareTo() method as well, which has already been done. Does this implicitly mean that I also should consider implementing an equals() method and a hashCode() method as well? The reason why I'm asking is because I stumbled upon this advice when searching through the project via FindBugs, and I'm trying to

project Can not execute Findbugs: java.lang.ArrayIndexOutOfBoundsException

牧云@^-^@ 提交于 2019-12-12 23:03:55
问题 I am using sonarQube4.5.7 version with JDK 1.8 version. currently getting this error on running mvn sonar:sonar command. can anyone suggest me how to resolve this error. Logs are: Unable to get XClass for java/lang/StringBuilder java.lang.ArrayIndexOutOfBoundsException: 26721 At org.objectweb.asm.ClassReader.readClass(Unknown Source) At org.objectweb.asm.ClassReader.accept(Unknown Source) At edu.umd.cs.findbugs.asm.FBClassReader.accept(FBClassReader.java:44) At org.objectweb.asm.ClassReader

Findbugs using jsr305 annotations in eclipse is not finding bugs

谁都会走 提交于 2019-12-12 15:08:58
问题 I've been experimenting with the jsr 305 annotations for use with Findbugs, specifically the @CheckForNull annotation which would have avoided a bug I just found making it out to customers. I've added jsr305.jar and annotations.jar to my build path but the bugs aren't found by findbugs. I'm using Eclipse with the Eclipse Findbugs plugin. Below is some sample code which shows the same bug but doesn't when I run findbugs over it find the bug. I have tried this in Eclipse Galileo and Ganymede.

FindBugs: “may fail to close stream” - is this valid in case of InputStream?

主宰稳场 提交于 2019-12-12 14:40:19
问题 In my Java code, I start a new process, then obtain its input stream to read it: BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); FindBugs reports an error here: may fail to close stream Pattern id: OS_OPEN_STREAM, type: OS, category: BAD_PRACTICE Must I close the InputStream of another process? And what's more, according to its Javadoc, InputStream#close() does nothing. So is this a false positive, or should I really close the input stream of the

Can FindBugs be used to flag code that uses a method that's been blacklisted?

☆樱花仙子☆ 提交于 2019-12-12 10:47:10
问题 We're trying to move our very large codebase from Guava 11 to Guava 14 and would like to catch uses of removed or deprecated APIs. Can FindBugs perform such checking? If so, how? 回答1: One solution would be to just use Oracle's Java compiler javac to do this. Removed methods in the API would result in compiler errors if they are used so it should be possible to find these by compiling the code. Deprecated methods can be found using the javac -deprecation option. More on -deprecation here: http

findbugs-maven-plugin doesn't do anything

微笑、不失礼 提交于 2019-12-12 10:34:39
问题 I don't get it... I want to enable findbugs report in a Maven 3 project site and did it by adding this to my pom.xml (As described here): <project> ... <reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> <version>2.4.0</version> </plugin> </plugins> </reporting> ... </project> Then I ran mvn site but no report is generated. Interesting thing is when I use version 2.3.1 instead then a report is generated. But 2.3.2 or 2.4.0 doesn't

Maven + FindBugs - fail on high-priority warning

↘锁芯ラ 提交于 2019-12-12 10:34:10
问题 I am using Maven and FindBugs on a large project. I would like to cause a maven build to fail if FindBugs yields any high priority errors. A simple parameter can be set within a pom.xml to fail on errors but I need it to fail on high priority warnings. Any suggestions would be huge! 回答1: I suspect you are already aware of the findbugs:check goal available for the plugin. Setting the threshold configuration item to High should limit the goal to failing only on High priority issues. Here is an

javax.annotation.Nonnull vs assert

≯℡__Kan透↙ 提交于 2019-12-12 09:34:32
问题 I'm using Findbugs and javax.annotation.Nonnull on method parameters. On private methods I usually add an assert line to check for nullness like private void myMethod(@Nonnull String str) { assert str != null .... Latest Netbeans version (7.3rc2) is reporting that the assert check is not necessary (because of the Nonnull annotation). I'm not fully sure this is a Netbeans bug or not. Can the assert line be removed because I specified the @Nonnull annotation ? As far as I understand, the

Method ignores exceptional return value : FindBugs

倖福魔咒の 提交于 2019-12-12 01:33:19
问题 Why the heading error in the findbugs for the following code. boolean isCreated = folder.mkdirs(); if (!isCreated) { throw new IOException("Folder already exists..!!!"); } 回答1: According to Finds Bug Description. Method ignores exceptional return value Method returns a value that is not checked. The return value should be checked since it can indicate an unusual or unexpected function execution. 回答2: Probably because you're not checking for the SecurityException that mkdirs can throw. 来源:

Can IntelliJ auto-generate code to null-check arguments when using @ParametersAreNonnullByDefault annotation on package

孤人 提交于 2019-12-11 15:05:10
问题 I like the feature where IntelliJ can automatically generate code to check at runtime for null on each argument/parameter passed to a method. This feature is enabled in Preferences > Build, Execution, Deployment > Compiler > Add runtime assertions for notnull-annotated methods and parameters (checkbox). The neighboring Configure annotations button configures which annotation package. I am trying to set my not-null annotation at the package level. Example: @ParametersAreNonnullByDefault