-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Ignore exception while closing stream to let awaitCompletion finish before time-out #1149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
try { | ||
stream.close(); | ||
} catch (IOException e) { | ||
LOGGER.debug("Error closing stream", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds like it could be set on error level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably - it is up to you guys to decide. My personal feeling is that #debug is enough but you guys have more experience what is better in such a case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other question is whether to leave @throws declaration as is and/or rethrow the exception (by putting complete.countDown in section finally).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That why i wanted to check a real case trace, probably upper levels needs to get this exception with the initial reason.
And i think user should know the reason of the exception and can handle it accordingly if he wants ignore it
Do you have stacktrace for the case when .close() thrown exception? Do you know how to reproduce it? |
I will try to provide something tomorrow :) |
Here it is the stacktrace that was thrown from stream#close:
|
Let's rethrow exception to keep original error, but count down latch. |
Codecov Report
@@ Coverage Diff @@
## master #1149 +/- ##
==========================================
+ Coverage 58.55% 58.56% +0.01%
==========================================
Files 451 451
Lines 8888 8891 +3
Branches 543 543
==========================================
+ Hits 5204 5207 +3
- Misses 3386 3387 +1
+ Partials 298 297 -1
Continue to review full report at Codecov.
|
PR updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Currently, any exception thrown by stream.close in ResultCallbackTemplate#close causes CountDownLatch complete to not being counted down and awaitCompletion to never end (or to wait until time-out).
This pull request ensures that calling LogContainerResultCallback#close will really close despite any errors thrown from stream.close() and let awaitCompletion finish before time-out. In this PR this exception will be logged on debug level and ignored.
This change is