Skip to content

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

Merged
merged 2 commits into from
Jan 17, 2019

Conversation

pskowronek
Copy link
Contributor

@pskowronek pskowronek commented Jan 16, 2019

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 Reviewable

try {
stream.close();
} catch (IOException e) {
LOGGER.debug("Error closing stream", e);
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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).

Copy link
Member

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

@KostyaSha
Copy link
Member

Do you have stacktrace for the case when .close() thrown exception? Do you know how to reproduce it?

@pskowronek
Copy link
Contributor Author

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 :)

@pskowronek
Copy link
Contributor Author

Here it is the stacktrace that was thrown from stream#close:

com.github.dockerjava.shaded.javax.ws.rs.ProcessingException: Error closing message content input stream.                                                                                                                                    
        at com.github.dockerjava.shaded.org.glassfish.jersey.message.internal.EntityInputStream.close(EntityInputStream.java:162)                                                                                                            
        at com.github.dockerjava.jaxrs.util.WrappedResponseInputStream.close(WrappedResponseInputStream.java:60)                                                                                                                           
        at java_io_Closeable$close$0.call(Unknown Source)                                                                                                                                                                                    
        at build_clc00gmw6qc0e540d2tockpuq$1$2.close(/home/mmisiolek/work/git/devops/prpc-launcher/build.gradle:1039)                                                                                                                        
        at com.github.dockerjava.core.async.ResultCallbackTemplate.close(ResultCallbackTemplate.java:78)                                                                                                                                     
        at java_io_Closeable$close.callCurrent(Unknown Source)                                                                                                                                                                              
        at build_clc00gmw6qc0e540d2tockpuq$1.onNext(/home/mmisiolek/work/git/devops/prpc-launcher/build.gradle:1054)                                                                                                                          
        at build_clc00gmw6qc0e540d2tockpuq$1.onNext(/home/mmisiolek/work/git/devops/prpc-launcher/build.gradle)                                                                                                                               
        at com.github.dockerjava.jaxrs.AbstrAsyncDockerCmdExec$1.onNext(AbstrAsyncDockerCmdExec.java:43)                                                                                                                                      
        at com.github.dockerjava.core.async.FrameStreamProcessor.processResponseStream(FrameStreamProcessor.java:31)                                                                                                                          
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:66)                                                                                                                                  
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)                                                                                                                                  
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)                                                                                                                                                                           
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)                                                                                                                       
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)                                                                                                                                                   
        at java.lang.Thread.run(Thread.java:748)                                                                                                                                                                                             
Caused by: com.github.dockerjava.shaded.org.apache.http.MalformedChunkCodingException: CRLF expected at end of chunk                                                                                                                       
        at com.github.dockerjava.shaded.org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:254)                                                                                                                 
        at com.github.dockerjava.shaded.org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:226)                                                                                                                    
        at com.github.dockerjava.shaded.org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:185)                                                                                                                        
        at com.github.dockerjava.shaded.org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:214)                                                                                                                          
        at com.github.dockerjava.shaded.org.apache.http.impl.io.ChunkedInputStream.close(ChunkedInputStream.java:317)                                                                                                                         
        at com.github.dockerjava.shaded.org.apache.http.impl.execchain.ResponseEntityProxy.streamClosed(ResponseEntityProxy.java:143)                                                                                                         
        at com.github.dockerjava.shaded.org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:228)                                                                                                                  
        at com.github.dockerjava.shaded.org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:172)                                                                                                                       
        at java.io.BufferedInputStream.close(BufferedInputStream.java:483)                                                                                                                                                                   
        at java.io.FilterInputStream.close(FilterInputStream.java:181)                                                                                                                                                                       
        at com.github.dockerjava.shaded.org.glassfish.jersey.apache.connector.ApacheConnector$2.close(ApacheConnector.java:659)                                                                                                              
        at java.io.FilterInputStream.close(FilterInputStream.java:181)                                                                                                                                                                      
        at com.github.dockerjava.shaded.org.glassfish.jersey.apache.connector.ApacheConnector$HttpClientResponseInputStream.close(ApacheConnector.java:636)                                                                                  
        at com.github.dockerjava.shaded.org.glassfish.jersey.message.internal.EntityInputStream.close(EntityInputStream.java:159)                                                                                                          
        ... 15 more

@KostyaSha
Copy link
Member

to never end (or to wait until time-out).

Let's rethrow exception to keep original error, but count down latch.

@codecov-io
Copy link

Codecov Report

Merging #1149 into master will increase coverage by 0.01%.
The diff coverage is 50%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
.../dockerjava/core/async/ResultCallbackTemplate.java 75.55% <50%> (-3.02%) ⬇️
...ava/netty/handler/FramedResponseStreamHandler.java 84.48% <0%> (+3.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d29559...d9c0e28. Read the comment docs.

@pskowronek
Copy link
Contributor Author

PR updated.

Copy link
Member

@KostyaSha KostyaSha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@KostyaSha KostyaSha merged commit 76053ab into docker-java:master Jan 17, 2019
@KostyaSha KostyaSha added this to the 3.1.0-rc-8 milestone Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants