Idle connection thread is not a daemon, so the JVM cannot exit without close()

Abierto Apto para principiantes
#241 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
networking

Línea de trabajo

Empieza en httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/HttpClientFactoryImpl.java: el constructor en las líneas 60-61 crea e inicia el hilo que monitoriza las conexiones inactivas, y la clase del hilo en las líneas 220-246 nunca llama a setDaemon. Reprodúcelo ejecutando un pequeño main que crea un B2StorageClient con la fábrica por defecto y termina sin llamar a close(), y luego comprueba si la JVM sigue activa. Está terminado cuando la JVM se cierra por sí sola y los tests existentes siguen pasando después de marcar el hilo como daemon antes de start().

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

Descripción

What happens

HttpClientFactoryImpl starts an IdleConnectionMonitorThread in its constructor, and the thread is never marked as a daemon. A program that creates a client and does not call close() on it keeps running after main returns, with no message. Calling close() is documented as the right way, but the hang is easy to hit in short programs and tests.

Where

httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/HttpClientFactoryImpl.java:60-61 (constructor creates and starts the thread) and :220-246 (the thread class, which does not call setDaemon(true); no setDaemon call exists anywhere in the repository).

Why it matters

Impact: Left behind (a running thread keeps the process alive), silent. Severity: Medium, because it only happens when the caller never closes the client (an unusual condition, since B2StorageClientImpl documents that close() should be called) and the workaround is to call close().

How to check

Found by reading the code, not reproduced. Read the constructor and the thread class. Running a small main that builds a B2StorageClient with the default factory and returns without closing it should leave the JVM running (a thread dump would show the monitor thread). Calling setDaemon(true) before start() would let the JVM exit.

Version

Seen at v6.5.0. Present on the default branch: present.

Lenguaje dominante
Java
Estrellas
103
Forks
23
Merge medio
5 d 8 h
PR fusionados (30 d)
3

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 Backblaze/b2-sdk-java

Todos los issues de Backblaze/b2-sdk-java

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.