I am having findbugs error for the below code,
if( obj instanceof CustomerData )
{
CustomerData customerData = (CustomerData)obj;
if (customerData == null)
{
errors.reject("Error", "Null data received");
}
}
Error Desc:
Redundant nullcheck of obj, which is known to be non-null in (Package and Method name, I have removed due to security violation)
This method contains a redundant check of a known non-null value against the constant null.
Please let me know what is the error in here.
instanceofreturns false if the argument isnull. So you don’t need another check.