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

Aberta
#243 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 3 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
Meio dia
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
backend

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Java
Estrelas
103
Forks
23
Merge médio
5d 8h
PRs com merge (30d)
3

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de Backblaze/b2-sdk-java

Todas as issues de Backblaze/b2-sdk-java

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.