TimurRakhmatullin86 opened a new pull request, #18236: URL: https://github.com/apache/iceberg/pull/18236
## Summary Several `catch (InterruptedException)` blocks across the codebase lose the thread's interrupt status by not calling `Thread.currentThread().interrupt()` before re-throwing or continuing. This violates the `InterruptedException` contract and prevents proper cooperative thread cancellation, which can cause threads to hang indefinitely during shutdown. **Impact**: When a thread's interrupt flag is silently cleared, the calling code cannot detect that an interrupt was requested. This is particularly problematic in lock acquisition (`MetastoreLock`), parallel task execution (`ParallelIterable`), and database operations (`JdbcCatalog`, `JdbcSnowflakeClient`). ## Changes 11 files across 7 modules, restoring interrupt status in 14 catch blocks: | Module | File | Catch blocks fixed | |--------|------|--------------------| | core | `ParallelIterable` | 1 (inconsistent with line 220 which correctly restores) | | core | `JdbcCatalog` | 1 (only `UncheckedInterruptedException` throw in codebase missing restore) | | snowflake | `JdbcSnowflakeClient` | 6 | | hive-metastore | `MetastoreLock` | 2 (replaced `Thread.interrupted()` which clears flag; split multi-catch) | | aws | `DynamoDbLockManager` | 1 | | kafka-connect | `KafkaUtils` | 1 (split multi-catch) | | kafka-connect | `Coordinator` | 1 | | flink (v1.20, v2.1, v2.2, v2.3) | `DataStatisticsCoordinator` | 4 (split multi-catch, one per Flink version) | ## How this was verified Each catch block was manually reviewed to confirm: 1. `InterruptedException` is caught (directly or via multi-catch) 2. `Thread.currentThread().interrupt()` is NOT called before re-throwing/continuing 3. The pattern is inconsistent with other catch blocks in the same file or codebase For `MetastoreLock.acquireLock()` (line 220), the existing code called `Thread.interrupted()` which actively *clears* the interrupt flag — the opposite of the correct behavior. The comment "Clear the interrupt status flag" confirms this was intentional but incorrect, as it prevents the calling code from detecting the interrupt. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
