File tree Expand file tree Collapse file tree 1 file changed +23
-7
lines changed
docker-java-api/src/main/java/com/github/dockerjava/api/async Expand file tree Collapse file tree 1 file changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -87,10 +87,18 @@ public void close() throws IOException {
8787 */
8888 @ SuppressWarnings ("unchecked" )
8989 public RC_T awaitCompletion () throws InterruptedException {
90- completed .await ();
91- // eventually (re)throws RuntimeException
92- throwFirstError ();
93- return (RC_T ) this ;
90+ try {
91+ completed .await ();
92+ // eventually (re)throws RuntimeException
93+ throwFirstError ();
94+ return (RC_T ) this ;
95+ } finally {
96+ try {
97+ close ();
98+ } catch (IOException e ) {
99+ LOGGER .debug ("Failed to close" , e );
100+ }
101+ }
94102 }
95103
96104 /**
@@ -99,9 +107,17 @@ public RC_T awaitCompletion() throws InterruptedException {
99107 * before {@link ResultCallback#onComplete()} was called.
100108 */
101109 public boolean awaitCompletion (long timeout , TimeUnit timeUnit ) throws InterruptedException {
102- boolean result = completed .await (timeout , timeUnit );
103- throwFirstError ();
104- return result ;
110+ try {
111+ boolean result = completed .await (timeout , timeUnit );
112+ throwFirstError ();
113+ return result ;
114+ } finally {
115+ try {
116+ close ();
117+ } catch (IOException e ) {
118+ LOGGER .debug ("Failed to close" , e );
119+ }
120+ }
105121 }
106122
107123 /**
You can’t perform that action at this time.
0 commit comments