Buggy code:
@ RequiredArgsConstructor @ Log4j public class Simulation { public enum Mode { MANUEL , AUTO ; } public enum Etat { NORMAL , SELECTION , CHOIX_DESTINATION_BAGAGE , CHOIX_DESTINATION_CHARIOT ; } @ Getter @ Setter private File xmlFile ; @ Getter @ NonNull private VueHall vueHall ; @ Getter private Hall hall ; @ Getter private Simulation . Mode mode ; @ Getter @ Setter private Simulation . Etat etat ; @ Getter private Clock clock ; @ Getter private VueElem selectedElem ; @ Getter @ Setter private LinkedList < Rail > railsFleches ; @ Setter private PropertiesWidget propertiesWidget ; public void init ( ) throws MalformedCircuitArchiveException , FileNotFoundException , IOException { } public void play ( ) { } public void pause ( ) { } public void stop ( ) { } public void setSpeed ( int refreshInterval ) { } public void setSelectedElem ( VueElem _selectedElem ) { } public boolean createBagage ( VueElem depart , VueElem destination ) { } public boolean createBagage ( VueElem depart ) { } public boolean createChariot ( VueElem depart ) { } public void setMode ( Simulation . Mode mode ) { deleteFleches ( ) ; if ( mode == ( Simulation . Mode . MANUEL ) ) { vueHall . getHall ( ) . setAutomatique ( false ) ; for ( int i = 0 ; i < ( vueHall . getHall ( ) . getFileBagageList ( ) . size ( ) ) ; i ++ ) { if ( ( vueHall . getHall ( ) . getFileBagageList ( ) . get ( i ) ) instanceof TapisRoulant ) { TapisRoulant tapis = ( ( TapisRoulant ) ( vueHall . getHall ( ) . getFileBagageList ( ) . get ( i ) ) ) ; tapis . setAutoBagageGeneration ( false ) ; } } ArrayList < Chariot > chariots = vueHall . getHall ( ) . getChariotList ( ) ; for ( int i = 0 ; i < ( chariots . size ( ) ) ; i ++ ) { <START_BUG> if ( ( ( chariots . get ( i ) . getCheminPrevu ( ) . size ( ) ) > 0 ) && ( ( chariots . get ( i ) . getCheminPrevu ( ) . peek ( ) ) instanceof Noeud ) ) { <END_BUG> LinkedList < ElementCircuit > newChemin = new LinkedList < ElementCircuit > ( ) ; newChemin . add ( chariots . get ( i ) . getCheminPrevu ( ) . peek ( ) ) ; chariots . get ( i ) . setCheminPrevu ( newChemin ) ; } else { chariots . get ( i ) . setCheminPrevu ( null ) ; } } } else if ( mode == ( Simulation . Mode . AUTO ) ) { vueHall . getHall ( ) . setAutomatique ( true ) ; for ( int i = 0 ; i < ( vueHall . getHall ( ) . getFileBagageList ( ) . size ( ) ) ; i ++ ) { if ( ( vueHall . getHall ( ) . getFileBagageList ( ) . get ( i ) ) instanceof TapisRoulant ) { TapisRoulant tapis = ( ( TapisRoulant ) ( vueHall . getHall ( ) . getFileBagageList ( ) . get ( i ) ) ) ; tapis . setAutoBagageGeneration ( true ) ; } } UtilsCircuit . getUtilsCircuit ( ) . resetTapisRoulantIncomingChariotsNumber ( ) ; ArrayList < Chariot > chariots = vueHall . getHall ( ) . getChariotList ( ) ; for ( int i = 0 ; i < ( chariots . size ( ) ) ; i ++ ) { Noeud nouvelleDestination ; if ( ( chariots . get ( i ) . getBagage ( ) ) == null ) { nouvelleDestination = UtilsCircuit . getUtilsCircuit ( ) . getTapisRoulantOptimalNext ( ) . getConnexionCircuit ( ) ; } else { nouvelleDestination = UtilsCircuit . getUtilsCircuit ( ) . getRandomExistingTobogan ( ) . getConnexionCircuit ( ) ; } Noeud noeudChariot = null ; if ( ( chariots . get ( i ) . getParent ( ) ) instanceof Noeud ) { noeudChariot = ( ( Noeud ) ( chariots . get ( i ) . getParent ( ) ) ) ; } else { noeudChariot = ( ( Rail ) ( chariots . get ( i ) . getParent ( ) ) ) . getNoeudSuivant ( ) ; } chariots . get ( i ) . setCheminPrevu ( vueHall . getHall ( ) . getCircuit ( ) . calculChemin ( noeudChariot , nouvelleDestination ) ) ; chariots . get ( i ) . setDestination ( nouvelleDestination ) ; } } else { log . warn ( "Mode<seq2seq4repair_space>non<seq2seq4repair_space>existant." ) ; return ; } this . mode = mode ; } public void refreshProperties ( ) { } public void displayFleches ( LinkedList < Rail > rails ) { } public void deleteFleches ( ) { } }

Fix:
if ( ( ( ( chariots . get ( i ) . getCheminPrevu ( ) ) != null ) && ( ( chariots . get ( i ) . getCheminPrevu ( ) . size ( ) ) > 0 ) ) && ( ( chariots . get ( i ) . getCheminPrevu ( ) . peek ( ) ) instanceof Noeud ) ) {