FindBugs Report

Project Information

Project:

FindBugs version: 3.0.1

Code analyzed:



Metrics

22173 lines of code analyzed, in 610 classes, in 29 packages.

Metric Total Density*
High Priority Warnings 3 0.14
Medium Priority Warnings 24 1.08
Total Warnings 27 1.22

(* Defects per Thousand lines of non-commenting source statements)



Contents

Summary

Warning Type Number
Bad practice Warnings 7
Internationalization Warnings 2
Multithreaded correctness Warnings 10
Performance Warnings 2
Dodgy code Warnings 6
Total 27

Warnings

Click on a warning row to see full context information.

Bad practice Warnings

Code Warning
Dm org.apache.kafka.common.utils.Exit$2.execute(int, String) invokes System.exit(...), which shuts down the entire virtual machine
ES Comparison of String objects using == or != in org.apache.kafka.common.config.ConfigDef.parseForValidate(String, Map, Map, Map)
ES Comparison of String objects using == or != in org.apache.kafka.common.config.ConfigDef.parseValue(ConfigDef$ConfigKey, Object, boolean)
ES Comparison of String objects using == or != in new org.apache.kafka.common.config.ConfigDef$ConfigKey(String, ConfigDef$Type, Object, ConfigDef$Validator, ConfigDef$Importance, String, String, int, ConfigDef$Width, String, List, ConfigDef$Recommender)
ES Comparison of String objects using == or != in org.apache.kafka.common.config.ConfigDef$ConfigKey.hasDefault()
NP org.apache.kafka.common.utils.Bytes.equals(Object) does not check for null argument
RV Exceptional return value of java.io.File.delete() ignored in org.apache.kafka.common.utils.Utils.delete(File)

Internationalization Warnings

Code Warning
Dm Found reliance on default encoding in org.apache.kafka.clients.producer.internals.ErrorLoggingCallback.onCompletion(RecordMetadata, Exception): new String(byte[])
Dm Found reliance on default encoding in org.apache.kafka.common.utils.Shell.runCommand(): new java.io.InputStreamReader(InputStream)

Multithreaded correctness Warnings

Code Warning
IS Inconsistent synchronization of org.apache.kafka.clients.consumer.internals.AbstractCoordinator.coordinator; locked 85% of time
IS Inconsistent synchronization of org.apache.kafka.clients.consumer.internals.AbstractCoordinator.heartbeatThread; locked 73% of time
IS Inconsistent synchronization of org.apache.kafka.common.record.CompressionType$MemoizingConstructorSupplier.value; locked 50% of time
IS Inconsistent synchronization of org.apache.kafka.common.security.kerberos.KerberosLogin.lastLogin; locked 66% of time
IS Inconsistent synchronization of org.apache.kafka.common.security.kerberos.KerberosLogin.loginContext; locked 50% of time
JLM Synchronization performed on java.util.concurrent.ConcurrentHashMap in org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient$UnsentRequests.clean()
JLM Synchronization performed on java.util.concurrent.ConcurrentHashMap in org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient$UnsentRequests.put(Node, ClientRequest)
JLM Synchronization performed on java.util.concurrent.ConcurrentHashMap in org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient$UnsentRequests.remove(Node)
UL org.apache.kafka.clients.producer.internals.BufferPool.allocate(int, long) does not release lock on all paths
VO Increment of volatile field org.apache.kafka.clients.producer.internals.ProducerBatch.attempts in org.apache.kafka.clients.producer.internals.ProducerBatch.reenqueued(long)

Performance Warnings

Code Warning
Dm org.apache.kafka.common.config.ConfigDef.<static initializer for ConfigDef>() invokes inefficient new String(String) constructor
WMI new org.apache.kafka.common.config.AbstractConfig(ConfigDef, Map, boolean) makes inefficient use of keySet iterator instead of entrySet iterator

Dodgy code Warnings

Code Warning
ICAST Integral division result cast to double or float in new org.apache.kafka.common.metrics.stats.Histogram$LinearBinScheme(int, double)
RCN Redundant nullcheck of line which is known to be null in org.apache.kafka.common.utils.Shell.runCommand()
SF Switch statement found in org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.authenticate() where one case falls through to the next case
SF Switch statement found in org.apache.kafka.common.utils.Crc32.update(byte[], int, int) where default case is missing
SF Switch statement found in org.apache.kafka.common.utils.Utils.murmur2(byte[]) where one case falls through to the next case
SF Switch statement found in org.apache.kafka.common.utils.Utils.murmur2(byte[]) where default case is missing

Details

DM_STRING_CTOR: Method invokes inefficient new String(String) constructor

Using the java.lang.String(String) constructor wastes memory because the object so constructed will be functionally indistinguishable from the String passed as a parameter.  Just use the argument String directly.

DM_EXIT: Method invokes System.exit(...)

Invoking System.exit shuts down the entire Java virtual machine. This should only been done when it is appropriate. Such calls make it hard or impossible for your code to be invoked by other code. Consider throwing a RuntimeException instead.

DM_DEFAULT_ENCODING: 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.

ES_COMPARING_STRINGS_WITH_EQ: Comparison of String objects using == or !=

This code compares java.lang.String objects for reference equality using the == or != operators. Unless both strings are either constants in a source file, or have been interned using the String.intern() method, the same string value may be represented by two different String objects. Consider using the equals(Object) method instead.

ICAST_IDIV_CAST_TO_DOUBLE: Integral division result cast to double or float

This code casts the result of an integral division (e.g., int or long division) operation to double or float. Doing division on integers truncates the result to the integer value closest to zero. The fact that the result was cast to double suggests that this precision should have been retained. What was probably meant was to cast one or both of the operands to double before performing the division. Here is an example:

int x = 2;
int y = 5;
// Wrong: yields result 0.0
double value1 =  x / y;

// Right: yields result 0.4
double value2 =  x / (double) y;

IS2_INCONSISTENT_SYNC: Inconsistent synchronization

The fields of this class appear to be accessed inconsistently with respect to synchronization.  This bug report indicates that the bug pattern detector judged that

A typical bug matching this bug pattern is forgetting to synchronize one of the methods in a class that is intended to be thread-safe.

You can select the nodes labeled "Unsynchronized access" to show the code locations where the detector believed that a field was accessed without synchronization.

Note that there are various sources of inaccuracy in this detector; for example, the detector cannot statically detect all situations in which a lock is held.  Also, even when the detector is accurate in distinguishing locked vs. unlocked accesses, the code in question may still be correct.

JLM_JSR166_UTILCONCURRENT_MONITORENTER: Synchronization performed on util.concurrent instance

This method performs synchronization an object that is an instance of a class from the java.util.concurrent package (or its subclasses). Instances of these classes have their own concurrency control mechanisms that are orthogonal to the synchronization provided by the Java keyword synchronized. For example, synchronizing on an AtomicBoolean will not prevent other threads from modifying the AtomicBoolean.

Such code may be correct, but should be carefully reviewed and documented, and may confuse people who have to maintain the code at a later date.

NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT: equals() method does not check for null argument

This implementation of equals(Object) violates the contract defined by java.lang.Object.equals() because it does not check for null being passed as the argument. All equals() methods should return false if passed a null value.

RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE: Redundant nullcheck of value known to be null

This method contains a redundant check of a known null value against the constant null.

RV_RETURN_VALUE_IGNORED_BAD_PRACTICE: Method ignores exceptional return value

This method returns a value that is not checked. The return value should be checked since it can indicate an unusual or unexpected function execution. For example, the File.delete() method returns false if the file could not be successfully deleted (rather than throwing an Exception). If you don't check the result, you won't notice if the method invocation signals unexpected behavior by returning an atypical return value.

SF_SWITCH_NO_DEFAULT: Switch statement found where default case is missing

This method contains a switch statement where default case is missing. Usually you need to provide a default case.

Because the analysis only looks at the generated bytecode, this warning can be incorrect triggered if the default case is at the end of the switch statement and the switch statement doesn't contain break statements for other cases.

SF_SWITCH_FALLTHROUGH: Switch statement found where one case falls through to the next case

This method contains a switch statement where one case branch will fall through to the next case. Usually you need to end this case with a break or return.

UL_UNRELEASED_LOCK: Method does not release lock on all paths

This method acquires a JSR-166 (java.util.concurrent) lock, but does not release it on all paths out of the method. In general, the correct idiom for using a JSR-166 lock is:

    Lock l = ...;
    l.lock();
    try {
        // do something
    } finally {
        l.unlock();
    }

VO_VOLATILE_INCREMENT: An increment to a volatile field isn't atomic

This code increments a volatile field. Increments of volatile fields aren't atomic. If more than one thread is incrementing the field at the same time, increments could be lost.

WMI_WRONG_MAP_ITERATOR: Inefficient use of keySet iterator instead of entrySet iterator

This method accesses the value of a Map entry, using a key that was retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup.