Skip to content

ProviderBase: JAX-WS controller http handler method returning a generic collection forces static type serialisation for that collection #73

Description

@ylexus

Example:

class Controller {
    @GET 
    public Collection<MyClass> getCollection {
        return Arrays.<MyClass>asList(new SubclassOfMyClass())
    }
}

class MyClass {
    public getA() {
       ...
    }
}
class SubclassOfMyClass extends MyClass {
    public getB() {
       ...
    }
}

When used with Jersey's JacksonFeature, JSON returned will only contain attribute A and not attribute B because static serialisation of the root type is forced and there is no way I can override that. If, however, I wrap the collection with some other non-generic type, then static serialisation will not be forced and I will get both attribute "a" and "b" in the JSON produced by this GET.

jackson-jaxrs-base version used is 2.5.4.

Issue originally reported against Jersey but they are inclined to blame jackson: https://java.net/jira/browse/JERSEY-2939.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions