jersey icon indicating copy to clipboard operation
jersey copied to clipboard

Problems serializing Java Map collection with EntityFiltering enabled

Open chrisolson443 opened this issue 8 years ago • 1 comments

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<String, String> col = new HashMap<>();

    public Map<String, String> getCol()
    {
        return col;
    }

    public void setCol(Map<String, String> 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

chrisolson443 avatar Dec 09 '17 00:12 chrisolson443

Hi , We are also facing the same issue with SelectableEntityFiltering 1 -When Resource class returns Java collection (ArrayList/HashMap) result: an exception is thrown containing this: "Can not resolve PropertyFilter with id 'java.util.HashMap'; no FilterProvider configured" 2 -Simple POJO which has a Java collection as it's only field: I this case empty response is returned .

Is there any work around or patch available for this issue ? Its really important for us. Can someone please reply to this ? Thanks in advance

rajucet11 avatar Jan 30 '18 06:01 rajucet11