Skip to content

Should return an empty array, empty list, or optional, instead of NULL  #193

@steve-donovan

Description

@steve-donovan

Description

As an example, the FlightOfferSearch class has an array representing Stops within a Segment. If there are no stops, the array is NULL and can cause an NPE when using java streams.

Its best practice to either return an Optional or return an empty collection to guard against NPE's.

Steps to Reproduce

  1. Make a call to Amadeus Shopping flightOffersSearch API using any available test env data
  2. Examine the returned FlightOfferSearch object. Collections, such as Stops, with no data, are returned with NULL assignment

Expected Behavior: Collections with no data should be empty, not NULL

Actual Behavior: Collections such as Stops have a NULL assignment, causing NPE when streaming is applied.

Stable Behavior? 100%

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions