Description
Hi!
What
Tested version: docker-java-core:3.4.0
I`ve noticed two problems when a certain error is thrown during execution of the docker-java commands (e.g image pull). If the request thread throws an Error (not an Exception!), then
- the call to dockerClient.pullImageCmd() will block and hang forever, and
- the error is swallowed and not visible to the application code (yet visible on System.err through the default JVM error handler for uncaught thread exceptions)
Why
The error in this case was caused by a using a wrong Docker host configuration (containing a unix socket url) on a Windows 10 machine. This leads to an java.lang.UnsatisfiedLinkError: Error looking up function 'socket'
error at execute(request)
in L269 of
As the catch in L277 only handles Exceptions, but not Errors, the callback.onError() method is never executing, so the CountdownLatch here is never triggered:
This makes the awaitCompletion() call here wait forever, although the command is not running anymore:
If it helps, i can also attach the full stacktrace :)
Proposed fix
I'd suggest catching not only Exception
but also UnsatisfiedLinkError
which in this case is a condition that allows regular error handling and continued operation. Searching the issues of this project, it looks like other people also got this type of error.
One might also catch Throwable, but as always this has a smell and might not be a good option for all cases. However it might still be better than swallowing the error and hanging forever.