aws / aws/aws-lambda-java-libs

Looks like jackson's annotations are ignored

Aberta
#491 3 comentários 0 reações 0 responsáveis Ver no GitHub
events-v4
Linguagem predominante
Java
Estrelas
548
Forks
241
Merge médio
2d 5min
PRs com merge (30d)
11

Descrição

From @botbfr, https://github.com/aws/aws-sdk-java/issues/2453.

## Describe the issue
I have overriden RequestHandler with my lambda. All the jackson's annotations in my pojo (PreSignUpEvent) are ignored (Tested with JsonProperty so far). => The attributes that does not require an annotation are correctly deserialized (Because the attribute's name is the same than the object attribute's name) but not the ones with 2 different names (that's why I need to use JsonProperty annotation)

I'm using jackson v2 annotations.

I tried with RequestStreamHandler, calling in my lambda 'new ObjectMapper().readValue(InputStream, MyPojo.class)' and it worked. The annotations are taken into account.

My pojo and the lambda (just for the example here, I tried with the field 'version' -> versionn):
```java
public class PreSignUpEvent {

@JsonProperty("version")
private int versionn;

private String region;

public PreSignUpEvent() {
}

public int getVersionn() {
return versionn;
}

public void setVersionn(int versionn) {
this.versionn = versionn;
}

public String getRegion() {
return region;
}

public void setRegion(String region) {
this.region = region;
}
@Named("validateUsername")
public class ValidateUsername implements RequestHandler {

@Override
public PreSignUpEvent handleRequest(PreSignUpEvent input, Context context) {
{
LambdaLogger logger = context.getLogger();
logger.log("input is "+input);
return input;
}
```
logs:

`{"region":"eu-west-1"}` and version is ignored.

Do you have any idea ? Is it link to a reflection issue ?

## Steps to Reproduce
Override `RequestHandler` lambda,
Create a pojo that needs annotations to be deserialized

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Comece reproduzindo o caminho de RequestHandler com o PreSignUpEvent fornecido e compare-o com o exemplo funcional de RequestStreamHandler e ObjectMapper. Rastreie como a entrada de RequestHandler é desserializada; considera-se concluído quando as anotações do Jackson, como @JsonProperty, são respeitadas para campos com nomes diferentes, enquanto os campos existentes com o mesmo nome continuam sendo desserializados corretamente.

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

Avaliação

Stack de tecnologia
aws, java
Domínio
api, backend
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

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