It's actually a JAX-WS embedded object like:

public class RecordedEvents
    implements Serializable, Cloneable, CopyTo, Equals, HashCode, ToString
{

    protected short returnedEventCount;
    @XmlElement(nillable = true)
    protected List<RecordedEventWrapper> returnedEvents;

    public List<RecordedEventWrapper> getReturnedEvents() {
        if (returnedEvents == null) {
            returnedEvents = new ArrayList<RecordedEventWrapper>();
        }
        return this.returnedEvents;
    }

    public void setReturnedEvents(List<RecordedEventWrapper> value) {
        this.returnedEvents = null;
        List<RecordedEventWrapper> draftl = this.getReturnedEvents();
        draftl.addAll(value);
    }

Then the JAX-RS DTO has:

    private RecordedEvents recordedEvents;

    public RecordedEventsDto(final String customerGuid, final String masIp,
            final Long maxAgeMs, final Long transId, final String stbMac,
            final Short startIndex, final Short maxEventCount) {
        super(customerGuid, masIp, maxAgeMs, transId);
        this.stbMac = stbMac;
        this.startIndex = startIndex;
        this.maxEventCount = maxEventCount;
        // IPVS needs empty lists
        recordedEvents = new RecordedEvents();
        recordedEvents.setReturnedEvents(new ArrayList<>());
    }

So returnedEvents is initilized as an empty ArrayList, thus if I get a
failure I should ge an empty List, but I get null. So it's actually the
JAX-WS object demarshalling as null instead of empty.


On Tue, May 24, 2016 at 3:20 PM, Romain Manni-Bucau <[email protected]>
wrote:

> Hi
>
> Johnzon shouldnt skip them by default. Do you return an empty array/list?
> Le 24 mai 2016 21:09, "sgjava" <[email protected]> a écrit :
>
> > I have a requirement where I need to return an empty collection instead
> of
> > null for null collections using JAX-RS. Is there such a setting in TomEE
> 7
> > for Johnzon?
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/JAX-RS-return-empty-collection-instead-of-null-tp4678582.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>



-- 
Steven P. Goldsmith

Reply via email to