Buggy code:
@ Service public class TicketServiceImpl implements TicketService { private static final Logger LOG = Logger . getLogger ( TicketServiceImpl . class . getName ( ) ) ; @ Autowired private TrainDao trainDao ; @ Autowired private ScheduleDao scheduleDao ; @ Autowired private StationDao stationDao ; @ Autowired private TicketDao ticketDao ; @ Autowired private PassengerDao passengerDao ; @ Autowired private UserDao userDao ; public TicketServiceImpl ( ) { } @ Override public TicketData buyTicket ( int userId , int trainNumber , Date departureDate , String stationName , PassengerData passengerData ) throws AlreadyRegisteredException , HasNoEmptySeatsException , InvalidInputDataException , SalesStopException { try { String name = passengerData . getName ( ) ; String surname = passengerData . getSurname ( ) ; Date birthdate = passengerData . getBirthdate ( ) ; Station station = stationDao . getStation ( stationName ) ; int stationId = station . getId ( ) ; Integer trainId = scheduleDao . getTrainId ( trainNumber , stationId , departureDate ) ; if ( trainId != null ) { Train train = trainDao . read ( trainId ) ; int countOfTickets = ticketDao . countOfTickets ( trainId ) ; int seats = train . getSeats ( ) ; if ( countOfTickets < seats ) { Passenger passenger = passengerDao . getPassenger ( name , surname , birthdate ) ; boolean newPassenger = false ; if ( passenger == null ) { newPassenger = true ; passenger = new Passenger ( ) ; passenger . setName ( name ) ; passenger . setSurname ( surname ) ; passenger . setBirthdate ( birthdate ) ; User user = userDao . read ( userId ) ; <START_BUG> List < Passenger > passengers = user . getPassengers ( ) ; <END_BUG> passengers . add ( passenger ) ; user . setPassengers ( passengers ) ; passengerDao . create ( passenger ) ; } if ( newPassenger || ( ! ( ticketDao . hasBeenRegistered ( trainId , passenger . getId ( ) ) ) ) ) { if ( DateHelper . hasMoreThanTenMinutes ( departureDate ) ) { Ticket ticket = new Ticket ( ) ; ticket . setTrain ( train ) ; ticket . setPassenger ( passenger ) ; ticket . setSaleTime ( new Date ( ) ) ; ticketDao . create ( ticket ) ; TicketData ticketData = new TicketData ( ) ; ticketData . setTrainNumber ( trainNumber ) ; ticketData . setStationFrom ( stationName ) ; ticketData . setDepartureDate ( departureDate ) ; ticketData . setPassengerData ( passengerData ) ; return ticketData ; } else { String message = ( "Departure<seq2seq4repair_space>date<seq2seq4repair_space>" + departureDate ) + "<seq2seq4repair_space>in<seq2seq4repair_space>less<seq2seq4repair_space>than<seq2seq4repair_space>10<seq2seq4repair_space>minutes." ; TicketServiceImpl . LOG . warn ( message ) ; throw new SalesStopException ( message ) ; } } else { String message = ( ( "Passenger:<seq2seq4repair_space>" + passengerData ) + "<seq2seq4repair_space>already<seq2seq4repair_space>registered<seq2seq4repair_space>on<seq2seq4repair_space>train<seq2seq4repair_space>with<seq2seq4repair_space>id:<seq2seq4repair_space>" ) + trainId ; TicketServiceImpl . LOG . warn ( message ) ; throw new AlreadyRegisteredException ( message ) ; } } else { String message = ( ( ( ( ( ( "Train<seq2seq4repair_space>with<seq2seq4repair_space>id:<seq2seq4repair_space>" + trainId ) + "<seq2seq4repair_space>has<seq2seq4repair_space>" ) + seats ) + "<seq2seq4repair_space>seats,<seq2seq4repair_space>" ) + countOfTickets ) + "<seq2seq4repair_space>" ) + "tickets<seq2seq4repair_space>has<seq2seq4repair_space>been<seq2seq4repair_space>sold." ; TicketServiceImpl . LOG . warn ( message ) ; throw new HasNoEmptySeatsException ( message ) ; } } else { String msg = ( ( "Train<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space>exception.<seq2seq4repair_space>trainNumber:<seq2seq4repair_space>" + trainNumber ) + "<seq2seq4repair_space>departureDate:<seq2seq4repair_space>" ) + departureDate ; TicketServiceImpl . LOG . warn ( msg ) ; throw new InvalidInputDataException ( msg ) ; } } catch ( NullPointerException e ) { StringBuilder msg = new StringBuilder ( "Possible<seq2seq4repair_space>that<seq2seq4repair_space>input<seq2seq4repair_space>information<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>valid:<seq2seq4repair_space>" ) ; if ( trainNumber <= 0 ) msg . append ( "trainNumber:<seq2seq4repair_space>" ) . append ( trainNumber ) ; if ( departureDate == null ) msg . append ( "departureDate:<seq2seq4repair_space>null" ) ; if ( stationName == null ) msg . append ( "stationFrom:<seq2seq4repair_space>null" ) ; if ( passengerData == null ) msg . append ( "passengerData:<seq2seq4repair_space>null" ) ; else { if ( ( passengerData . getName ( ) ) == null ) msg . append ( "passengerData:<seq2seq4repair_space>name<seq2seq4repair_space>is<seq2seq4repair_space>null" ) ; if ( ( passengerData . getSurname ( ) ) == null ) msg . append ( "passengerData:<seq2seq4repair_space>surname<seq2seq4repair_space>is<seq2seq4repair_space>null" ) ; if ( ( passengerData . getBirthdate ( ) ) == null ) msg . append ( "passengerData:<seq2seq4repair_space>birthdate<seq2seq4repair_space>is<seq2seq4repair_space>null" ) ; } TicketServiceImpl . LOG . warn ( msg . toString ( ) , e ) ; throw new InvalidInputDataException ( msg . toString ( ) , e ) ; } } @ Override public List < TicketData > getTickets ( String dateFromStr , String timeFromStr , String dateToStr , String timeToStr ) { } @ Override public boolean hasEmptySeats ( int trainNumber , String dispatchStationName , Date departureDate ) throws InvalidInputDataException { } @ Override public boolean hasEnoughTimeBeforeDeparture ( int trainNumber , String dispatchStationName , Date departureDate ) throws InvalidInputDataException { } @ Override public boolean isRegistered ( Integer trainNumber , String dispatchStation , Date departureDate , String firstName , String lastName , Date birthdate ) throws InvalidInputDataException { } @ Override public Float getTicketCost ( Integer trainNumber , String dispatchStation , Date date ) throws InvalidInputDataException { } }

Fix:
List < Passenger > passengers = new ArrayList < > ( ) ;