HwangRock opened a new pull request, #5288: URL: https://github.com/apache/zeppelin/pull/5288
### What is this PR for? The `catch (InterruptedException e)` block around `awaitTermination(...)` in `createOrUpdateSqlCompleter(...)` in `JDBCInterpreter` logs a warning and closes the connection, but never restores the interrupt status. Catching `InterruptedException` clears the thread's interrupt flag, so the interrupt is swallowed: callers on the completion request path can no longer detect it, and cooperative cancellation and shutdown signals are silently dropped. This is the classic swallowed-interrupt anti-pattern. This restores the interrupt with `Thread.currentThread().interrupt()` as the last statement of the block, after the connection-close attempt. Placing it last keeps the existing resource-release behavior running first, then leaves the interrupt status intact when the method returns so the calling thread can detect it. ### What type of PR is it? Bug Fix ### Todos * [x] Restore interrupt status in the `InterruptedException` catch block * [x] Add a unit test covering the restored interrupt status ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-6481 ### How should this be tested? * `./mvnw test -pl jdbc -Dtest=JDBCInterpreterTest` * New test `testCreateOrUpdateSqlCompleterRestoresInterruptStatusOnTimeout` pre-interrupts the calling thread so `awaitTermination(...)` throws `InterruptedException` immediately, drives the completer through the catch path, and asserts `Thread.currentThread().isInterrupted()` is `true` on return. Before the fix the flag is cleared and the assertion fails; after the fix it passes. 32 tests in the class pass. ### Screenshots (if appropriate) N/A ### Questions: * Does the license files need to update? No. * Is there breaking changes for older versions? No. * Does this needs documentation? No. -- 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]
