[Bug]: DockerDesktopClientProviderStrategy is always applicable

Abierto Apto para principiantes
#11,829 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
74/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
docker, java
Área
testing-qa

Línea de trabajo

Inspecciona DockerDesktopClientProviderStrategy, centrándote en socketPath, isApplicable() y getTransportConfig(). Empieza reproduciendo la selección de la estrategia en macOS sin Docker Desktop y, después, revisa las pruebas cercanas o la suite de pruebas de la estrategia. La tarea se considera completada cuando la estrategia no se selecciona si su socket no está disponible y no se produce ninguna NullPointerException mientras se intentan las configuraciones.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

type/bug
Module

Core

Testcontainers version

2.0.5

Using the latest Testcontainers version?

Yes

Host OS

macOS

Host Arch

ARM

Docker version
29.5.3
What happened?

DockerDesktopClientProviderStrategy is always applicable even when Docker Desktop is not installed at all. It happens because the socketPath field is annotated with @Getter(lazy = true) and so its actual type is AtomicReference, but the isApplicable() method checks nullability as this.socketPath != null.

@Getter(lazy = true)
@Nullable
private final Path socketPath = resolveSocketPath();

@Override
protected boolean isApplicable() {
    return (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC) && this.socketPath != null;
}

Finally, the getTransportConfig() method fails with NPE as getSocketPath() returns null.

@Override
public TransportConfig getTransportConfig() throws InvalidConfigurationException {
    return TransportConfig.builder().dockerHost(URI.create("unix://" + getSocketPath().toString())).build();
}
Relevant log output
[Test worker] ERROR o.t.d.DockerClientProviderStrategy - Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
	UnixSocketClientProviderStrategy: failed with exception InvalidConfigurationException (Could not find unix domain socket). Root cause NoSuchFileException (/var/run/docker.sock)
	DockerDesktopClientProviderStrategy: failed with exception NullPointerException (Cannot invoke "java.nio.file.Path.toString()" because the return value of "org.testcontainers.dockerclient.DockerDesktopClientProviderStrategy.getSocketPath()" is null)
Additional Information

No response

Lenguaje dominante
Java
Estrellas
8.7k
Forks
1.9k
Merge medio
2 d 17 h
PR fusionados (30 d)
9

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de testcontainers/testcontainers-java

Todos los issues de testcontainers/testcontainers-java

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.