In FindBugs, I am getting an issue like FCBL_FIELD_COULD_BE_LOCAL on the class name line of this code: How can I resolve this issue? Answer In order to resolve that issue you need to use you fields somewhere in your class. What FindBugs is telling you is that your fields in your class are never used as the fields. How you
Tag: findbugs
Getting rid of FindBugs “Random object created and used only once” when Random is created in the constructor
I want to get rid of the FindBugs warning “DMI: Random object created and used only once”. In the following example, the random number is generated only once upon the object construction. In other terms, for the lifecycle of a single instance of the class Wrap, no other instances of java.util.Random will be created. Is there a way to get
How to resolve findbug issue: Null passed for nonnull parameter
I’m getting the following findbugs error: “Method call passes null for nonnull parameter : Null passed for nonnull parameter of getApiStatus(ApiResponse)” If the apiResponse is null in the CallApi method (not shown here for brevity’s sake), it simply throws an exception that is caught in handleApiException and thrown again if we can’t do anything else about the exception. There is
Reliance on default encoding, what should I use and why?
FindBugs reports a bug: Reliance on default encoding Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly. I
How to suppress FindBugs warnings for fields or local variables?
I would like to suppress FindBugs warnings for specific fields or local variables. FindBugs documents that the Target can be Type, Field, Method, Parameter, Constructor, Package for its edu.umd.cs.findbugs.annotations.SuppressWarning annotation [1]. But it does not work for me to annotate the field, only when I annotate the method the warning gets suppressed. Annotating a whole method seems to broad to
What is the proper way to use a Logger in a Serializable Java class?
I have the following (doctored) class in a system I’m working on and Findbugs is generating a SE_BAD_FIELD warning and I’m trying to understand why it would say that before I fix it in the way that I thought I would. The reason I’m confused is because the description would seem to indicate that I had used no other non-serializable