Skip to content

Commit 774b2f7

Browse files
authored
API: Fix exception thrown in runSafely, suppress error prone warning (#5259)
1 parent eeb0af1 commit 774b2f7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

api/src/main/java/org/apache/iceberg/util/ExceptionUtil.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public static <R, E1 extends Exception, E2 extends Exception> R runSafely(
7878
return runSafely(block, catchBlock, finallyBlock, e1Class, e2Class, RuntimeException.class);
7979
}
8080

81+
@SuppressWarnings("Finally")
8182
public static <R, E1 extends Exception, E2 extends Exception, E3 extends Exception> R runSafely(
8283
Block<R, E1, E2, E3> block,
8384
CatchBlock catchBlock,
@@ -113,15 +114,15 @@ public static <R, E1 extends Exception, E2 extends Exception, E3 extends Excepti
113114
try {
114115
finallyBlock.run();
115116
} catch (Exception e) {
116-
LOG.warn("Suppressing failure in finally block", e);
117117
if (failure != null) {
118+
LOG.warn("Suppressing failure in finally block", e);
118119
failure.addSuppressed(e);
119120
} else {
120121
tryThrowAs(e, e1Class);
121122
tryThrowAs(e, e2Class);
122123
tryThrowAs(e, e3Class);
123124
tryThrowAs(e, RuntimeException.class);
124-
throw new RuntimeException("Unknown exception in finally block", failure);
125+
throw new RuntimeException("Unknown exception in finally block", e);
125126
}
126127
}
127128
}

0 commit comments

Comments
 (0)