Inline checkState() calls 08/116208/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 10 Apr 2025 10:04:30 +0000 (12:04 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 10 Apr 2025 10:04:30 +0000 (12:04 +0200)
We do not really need these, inline them to explicit throws.

Change-Id: I9a3a5e6881b5b9ad0b58b08030f3fac329809d46
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
atomix-storage/src/main/java/io/atomix/storage/journal/SegmentedByteBufJournal.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestBuilder.java

index 023e577619855585c25ad5f4ef2007bedd894d49..86ee5bf6325d42eae8bd795fbe809699236db87f 100644 (file)
@@ -17,7 +17,6 @@
 package io.atomix.storage.journal;
 
 import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
 import static java.util.Objects.requireNonNull;
 
 import io.netty.buffer.ByteBufAllocator;
@@ -136,7 +135,9 @@ public final class SegmentedByteBufJournal implements RaftJournal {
      * @throws IllegalStateException if the segment manager is not open
      */
     private void assertOpen() {
-        checkState(currentSegment != null, "journal not open");
+        if (currentSegment == null) {
+            throw new IllegalStateException("journal not open");
+        }
     }
 
     /**
index 322863ae7a72fd63b1d7d110bed04a2d1f93f85f..21b54a687ff36d1fd950e8d8180d05a95f7cc749 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
-import static com.google.common.base.Preconditions.checkState;
 import static java.util.Objects.requireNonNull;
 
 import java.util.ArrayList;
@@ -42,7 +41,9 @@ public final class ModifyTransactionRequestBuilder implements Identifiable<Trans
     }
 
     private void checkNotFinished() {
-        checkState(protocol == null, "Batch has already been finished");
+        if (protocol != null) {
+            throw new IllegalStateException("Batch has already been finished");
+        }
     }
 
     public ModifyTransactionRequestBuilder addModification(final TransactionModification modification) {
@@ -64,7 +65,9 @@ public final class ModifyTransactionRequestBuilder implements Identifiable<Trans
     }
 
     public ModifyTransactionRequestBuilder setSequence(final long sequence) {
-        checkState(!haveSequence, "Sequence has already been set");
+        if (haveSequence) {
+            throw new IllegalStateException("Sequence has already been set");
+        }
         this.sequence = sequence;
         haveSequence = true;
         return this;
@@ -95,7 +98,9 @@ public final class ModifyTransactionRequestBuilder implements Identifiable<Trans
     }
 
     public @NonNull ModifyTransactionRequest build() {
-        checkState(haveSequence, "Request sequence has not been set");
+        if (!haveSequence) {
+            throw new IllegalStateException("Request sequence has not been set");
+        }
 
         final ModifyTransactionRequest ret = new ModifyTransactionRequest(identifier, sequence, replyTo, modifications,
             protocol);