Ignore exception while closing stream to let awaitCompletion finish before time-out - #1149
Conversation
| try { | ||
| stream.close(); | ||
| } catch (IOException e) { | ||
| LOGGER.debug("Error closing stream", e); |
There was a problem hiding this comment.
sounds like it could be set on error level
There was a problem hiding this comment.
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.
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.
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. |
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