TimurRakhmatullin86 opened a new pull request, #59037: URL: https://github.com/apache/spark/pull/59037
### What changes were proposed in this pull request? This PR restores the thread interrupt status in several `catch (InterruptedException)` blocks that currently swallow the exception without calling `Thread.currentThread().interrupt()`. When a method catches `InterruptedException` and does not re-throw it, the Java concurrency contract requires restoring the interrupt flag so that callers higher up the call stack can detect the interruption. Failing to do so can cause threads to miss cancellation signals, leading to tasks that fail to terminate, resource leaks, or silent misbehavior in concurrent code. ### Why are the changes needed? Swallowing `InterruptedException` without restoring the interrupt status is a well-known Java concurrency anti-pattern (see Java Concurrency in Practice, Section 7.1.3, and [IBM DeveloperWorks](https://www.ibm.com/developerworks/library/j-jtp05236/)). Spark already follows the correct pattern in many places (e.g., `HiveServer2.java:152`, `RemoteBlockPushResolver.java:992`), and this PR aligns the remaining instances. Apache Spark has previously fixed similar issues (e.g., SPARK-51083 in `JavaUtils.java`), which shows awareness of this pattern. ### Fixed locations | File | Method | Issue | |------|--------|-------| | `LauncherServer.java` | `close()` | Swallows interrupt during `serverThread.join()` | | `LauncherServer.java` | `waitForClose()` | Swallows interrupt during `connThread.join()` | | `CLIService.java` | `getOperationStatus()` | Swallows interrupt during `Future.get()` | | `SessionManager.java` | `sleepFor()` | Swallows interrupt during `wait()` in timeout checker | | `SessionManager.java` | `stop()` | Swallows interrupt during `awaitTermination()` | | `SSLFactory.java` | `destroy()` | Swallows interrupt during trust manager cleanup | | `BlockStoreClient.java` | `getHostLocalDirs()` | Swallows interrupt during `createClient()` | ### Does this PR introduce _any_ user-facing change? No. This is a correctness fix for thread interrupt handling that does not change any public API or user-visible behavior. ### How was this patch tested? Manual code inspection. Each fix adds a single `Thread.currentThread().interrupt()` call after the existing catch logic, which is a safe, additive change that preserves the original behavior while correctly propagating the interrupt status. 🤖 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]
