close()
is being invoked on a value that is always null. If this statement is executed, a null pointer exception will occur. Another serious issue is the fact that the resource that is meant to be closed is not closed.
A null pointer is dereferenced here. This will lead to a NullPointerException
when the code is executed.
toArray()
result detected JAVA-S0386This code is casting the result of calling toArray()
on a collection to a subtype of Object[]
, as in:
BigDecimal
constructed from double
may be imprecise JAVA-S0008BigDecimal
s constructed from a double
may not be represented correctly.
System.exit()
should only be invoked within application entry points JAVA-S0060This method invokes System.exit()
, and is called by other code. This can prevent proper error handling and debugging.
equals
method does not handle null valued operands JAVA-S0110This implementation of equals
violates the contract defined by java.lang.Object.equals
because it does not check for null
being passed as the argument.
The method creates a database resource (such as a database connection or row) but does not appear to do any of the following: * Assign the resource to any fields
readLine()
result is read without a null check JAVA-S0220The result of invoking readLine()
is read without checking to see if it is null.
There is a null check for a field which is being synchronized on. Since the field is synchronized on, it is unlikely that it will be null
. If it is null
and then synchronized on, a NullPointerException
will be thrown on synchronization and the check would be pointless.
Math.max
and Math.min
JAVA-S0080This code tries to limit the value bounds using a construct such as:
An increment to a volatile field isn't atomic.
Entry
objects JS0425The entrySet()
method is allowed to return a view of the underlying Map
in which a single Entry
object is reused and returned during the iteration. As of Java 1.6, commonly used map structures may return the same entry object while iterating over their entrySet. When iterating through such a Map
, the Entry
value is only valid until you advance to the next iteration.
The code contains a conditional test that is performed twice, one right after the other.
A volatile reference to an array doesn't treat the array elements as volatile.
equals()
on an array, which is equivalent to ==
JAVA-S0348This method invokes the .equals(Object o)
method on an array. Since arrays do not override the equals
method of Object
, calling equals
on an array is the same as comparing their addresses. To compare the contents of the arrays, use java.util.Arrays.equals(Object[], Object[])
. To compare the addresses of the arrays, it would be less confusing to explicitly check pointer equality using ==
.
There is a complicated, subtle or wrong increment in this for loop. Are you sure this for loop is incrementing the correct variable? It appears that another variable is being initialized and checked by the for loop.
This identifier is reserved as a keyword in later versions of Java. If/when this code is migrated to a newer Java version, it will not compile unless the identifier is renamed.
Non-final class defines a clone
method that does not call super.clone
.
The class's static initializer creates an instance of the class before all of the static final fields are assigned. This may easily lead to a scenario where the static instance of this class may be used while in a partially constructed state.
There is a statement or branch within a catch block which, if executed, guarantees that the variable accessed at this point will be null, unless a runtime exception is thrown (for any reason) before the access.