Problems serializing Java Map collection with EntityFiltering enabled
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:
-
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.
-
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
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