[ZEPPELIN-6481] Restore interrupt status after InterruptedException in JDBC completion loading#5288
Merged
Merged
Conversation
…n JDBC completion loading The catch (InterruptedException e) block around awaitTermination(...) in createOrUpdateSqlCompleter(...) logged a warning and closed the connection but never restored the interrupt status. Catching InterruptedException clears the thread's interrupt flag, so the interrupt was swallowed and callers on the completion request path could no longer detect it, silently dropping cooperative cancellation and shutdown signals. Restore the interrupt status with Thread.currentThread().interrupt() as the last statement of the catch block, after the connection-close attempt. Add a unit test that pre-interrupts the calling thread, drives the completer through the catch path, and asserts the interrupt flag is restored on return.
Member
|
Merged into master (dfd8cf7). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR for?
The
catch (InterruptedException e)block aroundawaitTermination(...)increateOrUpdateSqlCompleter(...)inJDBCInterpreterlogs a warning and closes the connection, but never restores the interrupt status. CatchingInterruptedExceptionclears 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
InterruptedExceptioncatch blockWhat is the Jira issue?
How should this be tested?
./mvnw test -pl jdbc -Dtest=JDBCInterpreterTesttestCreateOrUpdateSqlCompleterRestoresInterruptStatusOnTimeoutpre-interrupts the calling thread soawaitTermination(...)throwsInterruptedExceptionimmediately, drives the completer through the catch path, and assertsThread.currentThread().isInterrupted()istrueon 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: