JSON map and URL parameter builders fail for types with a version parameter

Abierto
#243 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
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
backend

Línea de trabajo

Start in core/src/main/java/com/backblaze/b2/json/B2JsonObjectHandler.java. Compare the array allocation at line 457 in the normal deserialize path, which uses constructorParamCount and fills the version parameter around lines 492-494, with the two allocations at lines 504 and 536 in deserializeFromFieldNameToValueMap and deserializeFromUrlParameterMap. Done when a test class annotated with versionParam can be built through both methods without an IllegalArgumentException, and the version value is set there too.

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

Descripción

What happens

For a type that declares a versionParam, the normal deserialize path sizes its constructor argument array with constructorParamCount (fields plus the version parameter). deserializeFromFieldNameToValueMap and deserializeFromUrlParameterMap size it with fields.length, so the array is one element short and constructor.newInstance throws an unchecked IllegalArgumentException (wrong number of arguments) that is not turned into a B2JsonException.

Where

core/src/main/java/com/backblaze/b2/json/B2JsonObjectHandler.java:504 and :536 (compare :457, and :235-236 where constructorParamCount is set); the version parameter is filled in at :492-494 only on the normal path.

Why it matters

Impact: Availability (building the object fails), loud. Severity: High, because it only affects types that use versionParam and are built from a map or URL parameters (unusual), and no type in the SDK's main code uses versionParam.

How to check

Found by reading the code, not reproduced. Read the three array allocations. A test could define a @B2Json.type(versionParam = "v") class and call deserializeFromFieldNameToValueMap or deserializeFromUrlParameterMap on it. Using constructorParamCount and setting the version parameter in those two methods would fix it.

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.