From 85f6641a7eb963dd0d95b8a16c7e8505fc928085 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 25 Jun 2024 12:40:11 -0700 Subject: [PATCH] Allow 'npipe://' prefix in Docker host address Update `LocalHttpClientTransport` to support explicit `npipe://` prefix in the host name. This is the format used in the Docker config from v4.31.1 onward. Fixes gh-41199 --- .../docker/transport/LocalHttpClientTransport.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/LocalHttpClientTransport.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/LocalHttpClientTransport.java index 64b19c3cc2d..f9f6707a533 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/LocalHttpClientTransport.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/LocalHttpClientTransport.java @@ -116,6 +116,8 @@ final class LocalHttpClientTransport extends HttpClientTransport { */ private static class LocalConnectionSocketFactory implements ConnectionSocketFactory { + private static final String NPIPE_PREFIX = "npipe://"; + private final String host; LocalConnectionSocketFactory(String host) { @@ -124,10 +126,10 @@ final class LocalHttpClientTransport extends HttpClientTransport { @Override public Socket createSocket(HttpContext context) throws IOException { - if (Platform.isWindows()) { - return NamedPipeSocket.get(this.host); + if (this.host.startsWith(NPIPE_PREFIX)) { + return NamedPipeSocket.get(this.host.substring(NPIPE_PREFIX.length())); } - return DomainSocket.get(this.host); + return (!Platform.isWindows()) ? DomainSocket.get(this.host) : NamedPipeSocket.get(this.host); } @Override