Remove StorageException 01/116201/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 10 Apr 2025 07:27:45 +0000 (09:27 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 10 Apr 2025 08:28:17 +0000 (10:28 +0200)
Use UncheckedIOException, as all remaining users are just masking an
existing IOException.

JIRA: CONTROLLER-2137
Change-Id: I4886ee6e13a07759da0b4e4df698ab5ebabeb9bd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
atomix-storage/src/main/java/io/atomix/storage/journal/DiskFileReader.java
atomix-storage/src/main/java/io/atomix/storage/journal/DiskFileWriter.java
atomix-storage/src/main/java/io/atomix/storage/journal/JournalSegment.java
atomix-storage/src/main/java/io/atomix/storage/journal/JournalSegmentWriter.java
atomix-storage/src/main/java/io/atomix/storage/journal/SegmentedByteBufJournal.java
atomix-storage/src/main/java/io/atomix/storage/journal/StorageException.java [deleted file]

index 961ba3ba43e3459a6f3f529607d142392444a1fd..812b2a7d57e2c34a90c3873420c6be4760e3d7f8 100644 (file)
@@ -20,6 +20,7 @@ import static java.util.Objects.requireNonNull;
 
 import io.netty.buffer.ByteBuf;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.channels.FileChannel;
 import org.eclipse.jdt.annotation.NonNull;
 
@@ -96,7 +97,7 @@ final class DiskFileReader extends FileReader {
         try {
             bytesRead = buffer.writeBytes(channel, readPosition, readAtLeast);
         } catch (IOException e) {
-            throw new StorageException(e);
+            throw new UncheckedIOException(e);
         }
         verify(bytesRead >= readAtLeast, "Short read %s, expected %s", bytesRead, readAtLeast);
     }
index dc98419482d15c8540ab0d2955d86a19f82ffbc5..ae6cbfe044dc45870fb4fb09f449059de59cd95a 100644 (file)
@@ -21,6 +21,7 @@ import static java.util.Objects.requireNonNull;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.channels.FileChannel;
 
 /**
@@ -50,7 +51,7 @@ final class DiskFileWriter extends FileWriter {
         try {
             ZERO_ENTRY_HEADER.getBytes(0, channel, position, HEADER_BYTES);
         } catch (IOException e) {
-            throw new StorageException(e);
+            throw new UncheckedIOException(e);
         }
     }
 
@@ -64,7 +65,7 @@ final class DiskFileWriter extends FileWriter {
         try {
             entry.readBytes(channel, position, entry.readableBytes());
         } catch (IOException e) {
-            throw new StorageException(e);
+            throw new UncheckedIOException(e);
         }
     }
 
@@ -74,7 +75,7 @@ final class DiskFileWriter extends FileWriter {
             try {
                 channel.force(true);
             } catch (IOException e) {
-                throw new StorageException(e);
+                throw new UncheckedIOException(e);
             }
         }
     }
index 37bc464c554cca0e72868413902bd8201943b1f2..ce5f4fb2958646b6d123e12814ea09b248c400a6 100644 (file)
@@ -24,6 +24,7 @@ import io.atomix.storage.journal.index.JournalIndex;
 import io.atomix.storage.journal.index.Position;
 import io.atomix.storage.journal.index.SparseJournalIndex;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.file.Files;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -107,7 +108,7 @@ final class JournalSegment {
                 fileReader.release();
             }
         } catch (IOException e) {
-            throw new StorageException(e);
+            throw new UncheckedIOException(e);
         }
     }
 
@@ -161,7 +162,7 @@ final class JournalSegment {
         try {
             ret = ((Inactive) state).activate(this);
         } catch (IOException e) {
-            throw new StorageException(e);
+            throw new UncheckedIOException(e);
         }
         state = ret;
         return ret;
@@ -259,7 +260,7 @@ final class JournalSegment {
         try {
             file.close();
         } catch (IOException e) {
-            throw new StorageException(e);
+            throw new UncheckedIOException(e);
         }
     }
 
@@ -272,7 +273,7 @@ final class JournalSegment {
         try {
             Files.deleteIfExists(file.path());
         } catch (IOException e) {
-            throw new StorageException(e);
+            throw new UncheckedIOException(e);
         }
     }
 
index e6eb22e2c53b23ef22c8f6de88f473c6e602de75..78992508b725d7397b6dcb1420941ec886620c8b 100644 (file)
@@ -21,6 +21,7 @@ import static java.util.Objects.requireNonNull;
 import io.atomix.storage.journal.index.JournalIndex;
 import java.io.EOFException;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.raft.journal.ToByteBufMapper;
@@ -150,7 +151,7 @@ final class JournalSegmentWriter {
         try {
             fileWriter.flush();
         } catch (IOException e) {
-            throw new StorageException(e);
+            throw new UncheckedIOException(e);
         }
     }
 }
index 7580876d9b4bc74da5e76e5125d05f88b32ef06e..6b0af527f3d2c9f3e208fad78685b5fbcf04f7d2 100644 (file)
@@ -23,6 +23,7 @@ import static java.util.Objects.requireNonNull;
 import io.netty.buffer.ByteBufAllocator;
 import java.io.File;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.nio.file.Path;
 import java.util.Collection;
 import java.util.TreeMap;
@@ -97,7 +98,7 @@ public final class SegmentedByteBufJournal implements RaftJournal {
                 try {
                     return segment.file().size();
                 } catch (IOException e) {
-                    throw new StorageException(e);
+                    throw new UncheckedIOException(e);
                 }
             })
             .sum();
@@ -278,7 +279,7 @@ public final class SegmentedByteBufJournal implements RaftJournal {
                 .withUpdated(System.currentTimeMillis())
                 .build());
         } catch (IOException e) {
-            throw new StorageException(e);
+            throw new UncheckedIOException(e);
         }
 
         final var segment = new JournalSegment(file, storageLevel, maxEntrySize, indexDensity);
@@ -325,7 +326,7 @@ public final class SegmentedByteBufJournal implements RaftJournal {
                 try {
                     segmentFile = JournalSegmentFile.openExisting(filePath, allocator);
                 } catch (IOException e) {
-                    throw new StorageException(e);
+                    throw new UncheckedIOException(e);
                 }
 
                 // Load the segment.
diff --git a/atomix-storage/src/main/java/io/atomix/storage/journal/StorageException.java b/atomix-storage/src/main/java/io/atomix/storage/journal/StorageException.java
deleted file mode 100644 (file)
index 08774d2..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2015-2021 Open Networking Foundation
- * Copyright 2023 PANTHEON.tech, s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.atomix.storage.journal;
-
-/**
- * Log exception.
- *
- * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
- */
-public class StorageException extends RuntimeException {
-    @java.io.Serial
-    private static final long serialVersionUID = 1L;
-
-    public StorageException(final Throwable cause) {
-        super(cause);
-    }
-}