FindBugs Report

Project Information

Project:

FindBugs version: 3.0.1

Code analyzed:



Metrics

1149 lines of code analyzed, in 40 classes, in 8 packages.

Metric Total Density*
High Priority Warnings 1 0.87
Medium Priority Warnings 5 4.35
Total Warnings 6 5.22

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



Contents

Summary

Warning Type Number
Bad practice Warnings 1
Correctness Warnings 1
Performance Warnings 1
Dodgy code Warnings 3
Total 6

Warnings

Click on a warning row to see full context information.

Bad practice Warnings

Code Warning
IC Initialization of org.apache.kafka.connect.data.Schema accesses class org.apache.kafka.connect.data.SchemaBuilder, which isn't initialized yet

Correctness Warnings

Code Warning
ICAST int converted to long and passed as absolute time to new java.util.Date(long) in org.apache.kafka.connect.data.Time.toLogical(Schema, int)

Performance Warnings

Code Warning
Bx Primitive boxed just to call toString in org.apache.kafka.connect.data.Decimal.builder(int)

Dodgy code Warnings

Code Warning
UrF Unread public/protected field: org.apache.kafka.connect.connector.Connector.context
UrF Unread public/protected field: org.apache.kafka.connect.sink.SinkTask.context
UrF Unread public/protected field: org.apache.kafka.connect.source.SourceTask.context

Details

DM_BOXED_PRIMITIVE_TOSTRING: Method allocates a boxed primitive just to call toString

A boxed primitive is allocated just to call toString(). It is more effective to just use the static form of toString which takes the primitive value. So,

Replace...With this...
new Integer(1).toString()Integer.toString(1)
new Long(1).toString()Long.toString(1)
new Float(1.0).toString()Float.toString(1.0)
new Double(1.0).toString()Double.toString(1.0)
new Byte(1).toString()Byte.toString(1)
new Short(1).toString()Short.toString(1)
new Boolean(true).toString()Boolean.toString(true)

IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION: Superclass uses subclass during initialization

During the initialization of a class, the class makes an active use of a subclass. That subclass will not yet be initialized at the time of this use. For example, in the following code, foo will be null.

public class CircularClassInitialization {
    static class InnerClassSingleton extends CircularClassInitialization {
        static InnerClassSingleton singleton = new InnerClassSingleton();
    }

    static CircularClassInitialization foo = InnerClassSingleton.singleton;
}

ICAST_INT_2_LONG_AS_INSTANT: int value converted to long and used as absolute time

This code converts a 32-bit int value to a 64-bit long value, and then passes that value for a method parameter that requires an absolute time value. An absolute time value is the number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT. For example, the following method, intended to convert seconds since the epoch into a Date, is badly broken:

Date getDate(int seconds) { return new Date(seconds * 1000); }

The multiplication is done using 32-bit arithmetic, and then converted to a 64-bit value. When a 32-bit value is converted to 64-bits and used to express an absolute time value, only dates in December 1969 and January 1970 can be represented.

Correct implementations for the above method are:

// Fails for dates after 2037
Date getDate(int seconds) { return new Date(seconds * 1000L); }

// better, works for all dates
Date getDate(long seconds) { return new Date(seconds * 1000); }

URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD: Unread public/protected field

This field is never read.  The field is public or protected, so perhaps it is intended to be used with classes not seen as part of the analysis. If not, consider removing it from the class.