eclipse-ee4j / eclipse-ee4j/jersey

Problems serializing Java Map collection with EntityFiltering enabled

Open
#3,732 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

With EntityFiltering enabled (either SelectableEntityFiltering orEntityFilteringFeature), Java Map collections are either not being serialized at all or an Exception is thrown.

There are two scenarios that I have found that I believe are related:

1) Resource class returns Java collection (HashMap)
result: an exception is thrown containing this: "Can not resolve PropertyFilter with id 'java.util.HashMap'; no FilterProvider configured"
In JacksonObjectProvider.FilteringFilterProvider there appears to be logic for this, but The Collection object doesn't get a subfilter mapping because I don't think Jersey's ObjectGraphImpl gets called(where subfilters are populated). Lots of code to trace through, so I could be off here.

2) Simple POJO which has a Java collection as it's only field:

domain model:
```
@XmlRootElement
public class Bob
{
public Bob(){}
private Map col = new HashMap<>();

public Map getCol()
{
return col;
}

public void setCol(Map col)
{
this.col = col;
}
}
```

result: the collection values are missing. This is because the JacksonObjectProvider.FilteringFilterProvider defaults to a SimpleBeanPropertyFilter.filterOutAllExcept() PropertyFilter when it can't find a PropertyFilter(?), and since filterOutAllExcept() isn't passed anything, everthing is filtered out.

Thanks,
Chris

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.