Guosmilesmile commented on code in PR #16049:
URL: https://github.com/apache/iceberg/pull/16049#discussion_r3160498769
##########
flink/v1.20/flink/src/test/java/org/apache/iceberg/flink/maintenance/api/TestJdbcLockFactory.java:
##########
@@ -38,4 +45,61 @@ TriggerLockFactory lockFactory(String tableName) {
tableName,
properties);
}
+
+ @Test
+ void testSQLExceptionEnablesRetryInClientPool() throws Exception {
+ // Regression test for #15759: verify that removing the inner try-catch
allows
+ // ClientPoolImpl to retry on transient connection failures.
+ //
+ // Before the fix: inner catch converted SQLException ->
UncheckedSQLException
+ // (RuntimeException) inside the lambda. ClientPoolImpl only catches the
declared
+ // exception type (SQLException), so RuntimeException bypasses retry
entirely.
+ // After the fix: SQLException propagates naturally, ClientPoolImpl
catches it,
+ // and retries on transient connection exceptions.
+ Map<String, String> props = Maps.newHashMap();
+ props.put("username", "user");
+ props.put("password", "password");
+ String uri = "jdbc:sqlite:file::memory:?ic" +
UUID.randomUUID().toString().replace("-", "");
+
+ try (JdbcClientPool pool = new JdbcClientPool(1, uri, props)) {
+ AtomicInteger attempts = new AtomicInteger(0);
+
+ String result =
+ pool.run(
+ conn -> {
+ if (attempts.incrementAndGet() == 1) {
+ throw new SQLTransientConnectionException("transient
failure");
+ }
+ return "success";
Review Comment:
nit: newline.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]