<propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
</configuration>
</plugin>
-
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <failOnError>true</failOnError>
+ </configuration>
+ </plugin>
</plugins>
</build>
<scm>
import akka.persistence.SnapshotOffer;
import com.google.common.base.Stopwatch;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.Collections;
import org.opendaylight.controller.cluster.PersistentDataProvider;
log.debug("{}: Deserialized restore snapshot: {}", context.getId(), snapshot);
context.getSnapshotManager().apply(new ApplySnapshot(snapshot));
- } catch (Exception e) {
+ } catch (RuntimeException | ClassNotFoundException | IOException e) {
log.error("{}: Error deserializing snapshot restore", context.getId(), e);
}
}
*/
package org.opendaylight.controller.cluster.raft;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Serializable;
import java.util.List;
import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload;
electionTerm, electionVotedFor, serverConfig);
}
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but "
+ + "this is OK since this class is merely a DTO and does not process the byte[] internally. "
+ + "Also it would be inefficient to create a return copy as the byte[] could be large.")
public byte[] getState() {
return state;
}
*/
package org.opendaylight.controller.cluster.raft.base.messages;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
public class CaptureSnapshotReply {
private final byte [] snapshot;
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Stores a reference to an externally mutable byte[] "
+ + "object but this is OK since this class is merely a DTO and does not process byte[] internally. "
+ + "Also it would be inefficient to create a copy as the byte[] could be large.")
public CaptureSnapshotReply(byte [] snapshot) {
this.snapshot = snapshot;
}
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but "
+ + "this is OK since this class is merely a DTO and does not process the byte[] internally. "
+ + "Also it would be inefficient to create a return copy as the byte[] could be large.")
public byte [] getSnapshot() {
return snapshot;
}
package org.opendaylight.controller.cluster.raft.client.messages;
import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import javax.annotation.Nonnull;
/**
return id;
}
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but "
+ + "this is OK since this class is merely a DTO and does not process the byte[] internally. "
+ + "Also it would be inefficient to create a return copy as the byte[] could be large.")
@Nonnull
public byte[] getSnapshot() {
return snapshot;
private final long prevLogTerm;
// log entries to store (empty for heart beat - may send more than one for efficiency)
- private transient List<ReplicatedLogEntry> entries;
+ private final List<ReplicatedLogEntry> entries;
// leader's commitIndex
private final long leaderCommit;
package org.opendaylight.controller.cluster.raft.messages;
import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
private final Optional<Integer> lastChunkHashCode;
private final Optional<ServerConfigurationPayload> serverConfig;
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Stores a reference to an externally mutable byte[] "
+ + "object but this is OK since this class is merely a DTO and does not process byte[] internally. "
+ + "Also it would be inefficient to create a copy as the byte[] could be large.")
public InstallSnapshot(long term, String leaderId, long lastIncludedIndex, long lastIncludedTerm, byte[] data,
int chunkIndex, int totalChunks, Optional<Integer> lastChunkHashCode,
Optional<ServerConfigurationPayload> serverConfig) {
return lastIncludedTerm;
}
+ @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but "
+ + "this is OK since this class is merely a DTO and does not process the byte[] internally. "
+ + "Also it would be inefficient to create a return copy as the byte[] could be large.")
public byte[] getData() {
return data;
}
package org.opendaylight.controller.cluster.raft.persisted;
import com.google.common.collect.ImmutableList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.ByteArrayOutputStream;
import java.io.Externalizable;
import java.io.IOException;
private static final Logger LOG = LoggerFactory.getLogger(ServerConfigurationPayload.class);
private static final long serialVersionUID = 1L;
+ @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
+ + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
+ + "aren't serialized. FindBugs does not recognize this.")
private final List<ServerInfo> serverConfig;
private final boolean migrated;
private int serializedSize = -1;
- private ServerConfigurationPayload(final @Nonnull List<ServerInfo> serverConfig, boolean migrated) {
+ private ServerConfigurationPayload(@Nonnull final List<ServerInfo> serverConfig, boolean migrated) {
this.serverConfig = ImmutableList.copyOf(serverConfig);
this.migrated = migrated;
}
- public ServerConfigurationPayload(final @Nonnull List<ServerInfo> serverConfig) {
+ public ServerConfigurationPayload(@Nonnull final List<ServerInfo> serverConfig) {
this(serverConfig, false);
}
@Deprecated
- public static ServerConfigurationPayload createMigrated(final @Nonnull List<ServerInfo> serverConfig) {
+ public static ServerConfigurationPayload createMigrated(@Nonnull final List<ServerInfo> serverConfig) {
return new ServerConfigurationPayload(serverConfig, true);
}
return migrated;
}
- public @Nonnull List<ServerInfo> getServerConfig() {
+ @Nonnull
+ public List<ServerInfo> getServerConfig() {
return serverConfig;
}
tracker2.addChunk(3, chunk3, Optional.<Integer>absent());
Assert.fail();
} catch (SnapshotTracker.InvalidChunkException e) {
- e.getMessage().startsWith("Invalid chunk");
+ // expected
}
// The first chunk's index must at least be FIRST_CHUNK_INDEX
private final List<Object> messages = new ArrayList<>();
@Override public void onReceive(Object message) throws Exception {
- if (message.equals(ARE_YOU_READY)) {
+ if (ARE_YOU_READY.equals(message)) {
getSender().tell("yes", getSelf());
- return;
- }
-
- if (GET_ALL_MESSAGES.equals(message)) {
+ } else if (GET_ALL_MESSAGES.equals(message)) {
getSender().tell(new ArrayList<>(messages), getSelf());
} else if (CLEAR_MESSAGES.equals(message)) {
clear();