diff --git a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java index d53d20e1a7..0e2c471243 100644 --- a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java +++ b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java @@ -109,7 +109,8 @@ public synchronized int read() int dataout = EOF; if (available == EOF) { - Preconditions.checkState (buffers == null); //should have released by now, see below + Preconditions + .checkState(buffers == null); //should have released by now, see below } else { dataout = Byte.toUnsignedInt(buffers.get(bufferIndex).get()); } @@ -149,7 +150,8 @@ public synchronized int read(byte[] b, int off, int len) throws IOException { while (len > 0) { int available = prepareRead(len); if (available == EOF) { - Preconditions.checkState(buffers == null); //should have been released by now + Preconditions + .checkState(buffers == null); //should have been released by now return total != 0 ? total : EOF; } buffers.get(bufferIndex).get(b, off + total, available); @@ -167,7 +169,7 @@ public synchronized int read(byte[] b, int off, int len) throws IOException { } /** - * Determines if all data in the stream has been consumed + * Determines if all data in the stream has been consumed. * * @return true if EOF, false if more data is available */ @@ -176,8 +178,9 @@ private boolean blockStreamEOF() { return false; } else { // if there are any chunks, we better be at the last chunk for EOF - Preconditions.checkState (((chunks == null) || chunks.isEmpty() || - chunkIndex == (chunks.size() - 1)), "EOF detected, but not at the last chunk"); + Preconditions.checkState(((chunks == null) || chunks.isEmpty() || + chunkIndex == (chunks.size() - 1)), + "EOF detected, but not at the last chunk"); return true; } } @@ -247,7 +250,7 @@ private boolean buffersHaveData() { if (buffersRemaining()) { // move to next available buffer ++bufferIndex; - Preconditions.checkState (bufferIndex < buffers.size()); + Preconditions.checkState(bufferIndex < buffers.size()); } else { // no more buffers remaining break; diff --git a/hadoop-hdds/pom.xml b/hadoop-hdds/pom.xml index a4d77ac526..e7cced800b 100644 --- a/hadoop-hdds/pom.xml +++ b/hadoop-hdds/pom.xml @@ -189,6 +189,13 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> ${junit.jupiter.version} test + + + com.google.code.findbugs + findbugs + 3.0.1 + provided + diff --git a/hadoop-hdds/server-scm/pom.xml b/hadoop-hdds/server-scm/pom.xml index aff0d29b09..33534cd4f8 100644 --- a/hadoop-hdds/server-scm/pom.xml +++ b/hadoop-hdds/server-scm/pom.xml @@ -100,6 +100,11 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.bouncycastle bcprov-jdk15on + + com.google.code.findbugs + findbugs + provided + diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java index 2b6c61b1e8..8e0b62bacc 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hdds.scm.pipeline; import com.google.common.base.Preconditions; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor; import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType; @@ -328,13 +329,13 @@ Pipeline updatePipelineState(PipelineID pipelineID, PipelineState state) return updatedPipeline; } - private class PipelineQuery { + private static class PipelineQuery { private ReplicationType type; private ReplicationFactor factor; PipelineQuery(ReplicationType type, ReplicationFactor factor) { - this.type = type; - this.factor = factor; + this.type = Preconditions.checkNotNull(type); + this.factor = Preconditions.checkNotNull(factor); } PipelineQuery(Pipeline pipeline) { @@ -343,6 +344,7 @@ private class PipelineQuery { } @Override + @SuppressFBWarnings("NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT") public boolean equals(Object other) { if (this == other) { return true; diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/RatisPipelineProvider.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/RatisPipelineProvider.java index ea7d370096..6126d580c2 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/RatisPipelineProvider.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/RatisPipelineProvider.java @@ -38,6 +38,8 @@ import java.util.Set; import java.util.stream.Collectors; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * Implements Api for creating ratis pipelines. */ @@ -48,6 +50,8 @@ public class RatisPipelineProvider implements PipelineProvider { private final Configuration conf; private static Scheduler scheduler; + //TODO static Scheduler should be removed!!!! HDDS-1128 + @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") RatisPipelineProvider(NodeManager nodeManager, PipelineStateManager stateManager, Configuration conf) { this.nodeManager = nodeManager; diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java index 8baa03beaf..e03293a8f1 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.net.InetSocketAddress; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -357,6 +358,6 @@ public static String getOMRatisDirectory(Configuration conf) { } private UUID getRaftGroupIdFromOmServiceId(String omServiceId) { - return UUID.nameUUIDFromBytes(omServiceId.getBytes()); + return UUID.nameUUIDFromBytes(omServiceId.getBytes(StandardCharsets.UTF_8)); } }