Enable modernizer in atomix-storage 05/104705/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Mar 2023 11:05:49 +0000 (12:05 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Mar 2023 11:06:28 +0000 (12:06 +0100)
There are only a few checkNotNull() violations, migrate them and enable
modernizer.

JIRA: CONTROLLER-2071
Change-Id: I8182ca3963e69a9029aa2ba458b76d16c4674d8a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
third-party/atomix/storage/pom.xml
third-party/atomix/storage/src/main/java/io/atomix/storage/journal/JournalSegmentDescriptor.java
third-party/atomix/storage/src/main/java/io/atomix/storage/journal/JournalSegmentFile.java
third-party/atomix/storage/src/main/java/io/atomix/storage/journal/SegmentedJournal.java
third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/Namespace.java

index ee6aa905a391c4e0e9ae9cc6b75074ae79c43ae8..51f3f98196143981d6d19c2f70466b87e1b1aa4b 100644 (file)
@@ -30,7 +30,6 @@
 
   <properties>
     <odlparent.checkstyle.skip>true</odlparent.checkstyle.skip>
-    <odlparent.modernizer.skip>true</odlparent.modernizer.skip>
     <odlparent.spotbugs.skip>true</odlparent.spotbugs.skip>
   </properties>
 
index 71ad15e398ccc51c08cf523bcaaf685485de30de..28072cec4dd9d60c3f2e8988a3628559f033adb2 100644 (file)
@@ -20,7 +20,7 @@ import com.google.common.annotations.VisibleForTesting;
 import java.nio.ByteBuffer;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
 
 /**
  * Stores information about a {@link JournalSegment} of the log.
@@ -226,7 +226,7 @@ public final class JournalSegmentDescriptor {
     private final ByteBuffer buffer;
 
     private Builder(ByteBuffer buffer) {
-      this.buffer = checkNotNull(buffer, "buffer cannot be null");
+      this.buffer = requireNonNull(buffer, "buffer cannot be null");
       buffer.putInt(VERSION_POSITION, VERSION);
     }
 
index 9fe7f12ed581c5f17edbc103eb7c6ae87f34de2b..5fe226d3bb0e7a5cd909c2f38268916f52b43681 100644 (file)
@@ -17,7 +17,7 @@ package io.atomix.storage.journal;
 
 import java.io.File;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
 
 /**
  * Segment file utility.
@@ -47,8 +47,8 @@ public final class JournalSegmentFile {
    * @throws NullPointerException if {@code file} is null
    */
   public static boolean isSegmentFile(String journalName, String fileName) {
-    checkNotNull(journalName, "journalName cannot be null");
-    checkNotNull(fileName, "fileName cannot be null");
+    requireNonNull(journalName, "journalName cannot be null");
+    requireNonNull(fileName, "fileName cannot be null");
 
     int partSeparator = fileName.lastIndexOf(PART_SEPARATOR);
     int extensionSeparator = fileName.lastIndexOf(EXTENSION_SEPARATOR);
@@ -73,7 +73,7 @@ public final class JournalSegmentFile {
    * Creates a segment file for the given directory, log name, segment ID, and segment version.
    */
   static File createSegmentFile(String name, File directory, long id) {
-    return new File(directory, String.format("%s-%d.log", checkNotNull(name, "name cannot be null"), id));
+    return new File(directory, String.format("%s-%d.log", requireNonNull(name, "name cannot be null"), id));
   }
 
   /**
index 4fb4a7459f59c4236c4f14c8d5d04aaa88c502a2..419a67e5fba2dba00a4bd37e92b7a0ec9ac85cfb 100644 (file)
@@ -35,8 +35,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
 
 /**
  * Segmented journal.
@@ -83,10 +83,10 @@ public class SegmentedJournal<E> implements Journal<E> {
       int maxEntriesPerSegment,
       double indexDensity,
       boolean flushOnCommit) {
-    this.name = checkNotNull(name, "name cannot be null");
-    this.storageLevel = checkNotNull(storageLevel, "storageLevel cannot be null");
-    this.directory = checkNotNull(directory, "directory cannot be null");
-    this.namespace = checkNotNull(namespace, "namespace cannot be null");
+    this.name = requireNonNull(name, "name cannot be null");
+    this.storageLevel = requireNonNull(storageLevel, "storageLevel cannot be null");
+    this.directory = requireNonNull(directory, "directory cannot be null");
+    this.namespace = requireNonNull(namespace, "namespace cannot be null");
     this.maxSegmentSize = maxSegmentSize;
     this.maxEntrySize = maxEntrySize;
     this.maxEntriesPerSegment = maxEntriesPerSegment;
@@ -696,7 +696,7 @@ public class SegmentedJournal<E> implements Journal<E> {
      * @return The storage builder.
      */
     public Builder<E> withName(String name) {
-      this.name = checkNotNull(name, "name cannot be null");
+      this.name = requireNonNull(name, "name cannot be null");
       return this;
     }
 
@@ -709,7 +709,7 @@ public class SegmentedJournal<E> implements Journal<E> {
      * @return The storage builder.
      */
     public Builder<E> withStorageLevel(StorageLevel storageLevel) {
-      this.storageLevel = checkNotNull(storageLevel, "storageLevel cannot be null");
+      this.storageLevel = requireNonNull(storageLevel, "storageLevel cannot be null");
       return this;
     }
 
@@ -723,7 +723,7 @@ public class SegmentedJournal<E> implements Journal<E> {
      * @throws NullPointerException If the {@code directory} is {@code null}
      */
     public Builder<E> withDirectory(String directory) {
-      return withDirectory(new File(checkNotNull(directory, "directory cannot be null")));
+      return withDirectory(new File(requireNonNull(directory, "directory cannot be null")));
     }
 
     /**
@@ -736,7 +736,7 @@ public class SegmentedJournal<E> implements Journal<E> {
      * @throws NullPointerException If the {@code directory} is {@code null}
      */
     public Builder<E> withDirectory(File directory) {
-      this.directory = checkNotNull(directory, "directory cannot be null");
+      this.directory = requireNonNull(directory, "directory cannot be null");
       return this;
     }
 
@@ -747,7 +747,7 @@ public class SegmentedJournal<E> implements Journal<E> {
      * @return The journal builder.
      */
     public Builder<E> withNamespace(Namespace namespace) {
-      this.namespace = checkNotNull(namespace, "namespace cannot be null");
+      this.namespace = requireNonNull(namespace, "namespace cannot be null");
       return this;
     }
 
index 6ebd044c9d98ed808e2987ec01d73349ce961652..1d16920a672c1829583568a184837aef5a54a6f3 100644 (file)
@@ -39,7 +39,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Objects;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
 import static org.slf4j.LoggerFactory.getLogger;
 
 /**
@@ -175,7 +175,7 @@ public final class Namespace implements KryoFactory, KryoPool {
      * @return this
      */
     public Builder register(Serializer<?> serializer, final Class<?>... classes) {
-      types.add(Pair.of(classes, checkNotNull(serializer)));
+      types.add(Pair.of(classes, requireNonNull(serializer)));
       return this;
     }
 
@@ -279,7 +279,7 @@ public final class Namespace implements KryoFactory, KryoPool {
     this.registrationRequired = registrationRequired;
     this.classLoader = classLoader;
     this.compatible = compatible;
-    this.friendlyName = checkNotNull(friendlyName);
+    this.friendlyName = requireNonNull(friendlyName);
   }
 
   /**