Skip to content

Commit

Permalink
Suppress findbugs false positive warnings.
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Barker <sbarker@redhat.com>
  • Loading branch information
SamBarker committed Feb 1, 2023
1 parent 27c6713 commit dfc12ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.7.2</version>

</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.kafka.clients.admin.Admin;
import org.apache.kafka.clients.admin.DescribeClusterResult;
import org.apache.kafka.clients.admin.DescribeLogDirsResult;
Expand All @@ -27,7 +28,7 @@
/**
* Leverages <a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-827%3A+Expose+log+dirs+total+and+usable+space+via+Kafka+API">KIP-827</a>
* to gather volume usage statistics for each Kafka log dir reported by the cluster.
*
* <p>
* A listener is registered with this volume source to act on the disk usage information.
*/
public class ClusterVolumeSource implements Runnable {
Expand All @@ -41,6 +42,7 @@ public class ClusterVolumeSource implements Runnable {
* @param admin The Kafka Admin client to be used for gathering inf
* @param volumeConsumer the listener to be notified of the volume usage.
*/
@SuppressFBWarnings("EI_EXPOSE_REP2") //Injecting the dependency is the right move as it can be shared
public ClusterVolumeSource(Admin admin, Consumer<Collection<Volume>> volumeConsumer) {
this.volumeConsumer = volumeConsumer;
this.admin = admin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.function.Function;
import java.util.function.Supplier;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.kafka.clients.admin.Admin;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.LogDirDescription;
Expand All @@ -30,14 +31,15 @@ public class VolumeSourceBuilder implements AutoCloseable {
* Default production constructor for production usage.
* Which will lazily create a Kafka admin client using the supplied config.
*/
@SuppressFBWarnings("MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR") //false positive we are just passing the method reference
public VolumeSourceBuilder() {
this(VolumeSourceBuilder::testForKip827, kafkaClientConfig -> AdminClient.create(kafkaClientConfig.getKafkaClientConfig()));
}

/**
* Secondary constructor visible for testing.
* @param kip827Available used to determine if KIP-827 API's are available
* @param adminClientFactory factory function for creating Admin clients with the builders config.
* @param adminClientFactory factory function for creating Admin clients with the builders' config.
*/
/* test */ VolumeSourceBuilder(Supplier<Boolean> kip827Available, Function<StaticQuotaConfig.KafkaClientConfig, Admin> adminClientFactory) {
this.kip827Available = kip827Available;
Expand Down

0 comments on commit dfc12ab

Please sign in to comment.