Skip to content

Commit a600e9e

Browse files
committed
throw IOException instead of Exception
1 parent ed5f1c2 commit a600e9e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

fluss-server/src/main/java/org/apache/fluss/server/log/LogLoader.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.io.File;
3333
import java.io.IOException;
3434
import java.nio.file.Files;
35+
import java.nio.file.NoSuchFileException;
3536
import java.util.ArrayList;
3637
import java.util.Arrays;
3738
import java.util.Comparator;
@@ -81,7 +82,7 @@ public LogLoader(
8182
*
8283
* @return the offsets of the Log successfully loaded from disk
8384
*/
84-
public LoadedLogOffsets load() throws Exception {
85+
public LoadedLogOffsets load() throws IOException {
8586
// load all the log and index files.
8687
logSegments.close();
8788
logSegments.clear();
@@ -130,7 +131,7 @@ public LoadedLogOffsets load() throws Exception {
130131
* @throws LogSegmentOffsetOverflowException if the segment contains messages that cause index
131132
* offset overflow
132133
*/
133-
private int recoverSegment(LogSegment segment) throws Exception {
134+
private int recoverSegment(LogSegment segment) throws IOException {
134135
WriterStateManager writerStateManager =
135136
new WriterStateManager(
136137
logSegments.getTableBucket(),
@@ -264,7 +265,7 @@ private void removeAndDeleteSegments(Iterator<LogSegment> segmentsToDelete) {
264265
}
265266

266267
/** Loads segments from disk into the provided segments. */
267-
private void loadSegmentFiles() throws Exception {
268+
private void loadSegmentFiles() throws IOException {
268269
File[] sortedFiles = logTabletDir.listFiles();
269270
if (sortedFiles != null) {
270271
Arrays.sort(sortedFiles, Comparator.comparing(File::getName));
@@ -288,8 +289,8 @@ private void loadSegmentFiles() throws Exception {
288289

289290
try {
290291
segment.sanityCheck(timeIndexFileNewlyCreated);
291-
} catch (Exception e) {
292-
if (e instanceof NoSuchFieldException) {
292+
} catch (IOException e) {
293+
if (e instanceof NoSuchFileException) {
293294
if (isCleanShutdown
294295
|| segment.getBaseOffset() < recoveryPointCheckpoint) {
295296
LOG.error(

fluss-server/src/main/java/org/apache/fluss/server/log/LogSegment.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
import java.io.File;
4646
import java.io.IOException;
47+
import java.nio.file.NoSuchFileException;
4748
import java.util.Optional;
4849

4950
import static org.apache.fluss.record.LogRecordBatchFormat.V0_RECORD_BATCH_HEADER_SIZE;
@@ -172,7 +173,7 @@ public void resizeIndexes(int size) throws IOException {
172173
timeIndex().resize(size);
173174
}
174175

175-
public void sanityCheck(boolean timeIndexFileNewlyCreated) throws Exception {
176+
public void sanityCheck(boolean timeIndexFileNewlyCreated) throws IOException {
176177
if (lazyOffsetIndex.file().exists()) {
177178
// Resize the time index file to 0 if it is newly created.
178179
if (timeIndexFileNewlyCreated) {
@@ -182,7 +183,7 @@ public void sanityCheck(boolean timeIndexFileNewlyCreated) throws Exception {
182183
// we will recover the segments above the recovery point in recoverLog()
183184
// in any case so sanity checking them here is redundant.
184185
} else {
185-
throw new NoSuchFieldException(
186+
throw new NoSuchFileException(
186187
"Offset index file "
187188
+ lazyOffsetIndex.file().getAbsolutePath()
188189
+ " does not exist.");
@@ -301,7 +302,7 @@ public boolean deleted() {
301302
* Run recovery on the given segment. This will rebuild the index from the log file and lop off
302303
* any invalid bytes from the end of the log and index.
303304
*/
304-
public int recover() throws Exception {
305+
public int recover() throws IOException {
305306
offsetIndex().reset();
306307
timeIndex().reset();
307308
int validBytes = 0;

0 commit comments

Comments
 (0)