Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DockerClient commands may hang forever after certain errors #2350

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

Open
lukaseckert opened this issue Jul 26, 2024 · 1 comment
Open

DockerClient commands may hang forever after certain errors #2350

lukaseckert opened this issue Jul 26, 2024 · 1 comment

Comments

@lukaseckert
Copy link

lukaseckert commented Jul 26, 2024

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

try (DockerHttpClient.Response response = execute(request)) {
callback.onStart(() -> {
streamingThread.interrupt();
response.close();
});
sourceConsumer.accept(response);
callback.onComplete();
} catch (Exception e) {
callback.onError(e);
}

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:
public RC_T awaitCompletion() throws InterruptedException {
try {
completed.await();

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.

Copy link

stale bot commented Apr 26, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant