Buggy code:
@ Service public class OrderStatesService { @ Autowired private DataDefinitionService dataDefinitionService ; @ Autowired private TranslationService translationService ; @ Autowired private PluginAccessor pluginAccessor ; private final Set < OrderStatesService . BeforeChangeStateListener > beforeChangeStateListeners = new HashSet < OrderStatesService . BeforeChangeStateListener > ( ) ; private void changeOrderStateTo ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final OrderStates oldState , final OrderStates newState ) { } public void changeOrderStateToAccepted ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } public void changeOrderStateToInProgress ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } public void changeOrderStateToCompleted ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } public void changeOrderStateToDeclined ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } public void changeOrderStateToAbandoned ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } public void changeOrderStateToInterrupted ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } private void changeOrderStateToForGrid ( final ComponentState state , final Long id , final OrderStates oldState , final OrderStates newState ) { Entity order = dataDefinitionService . get ( PLUGIN_IDENTIFIER , MODEL_ORDER ) . get ( id ) ; order . setField ( "state" , newState . getStringValue ( ) ) ; if ( ( hasIntegrationWithExternalSystem ( ) ) && ( StringUtils . hasText ( order . getStringField ( "externalNumber" ) ) ) ) { order . setField ( "externalSynchronized" , false ) ; } else { order . setField ( "externalSynchronized" , true ) ; } for ( OrderStatesService . BeforeChangeStateListener listener : beforeChangeStateListeners ) { if ( ! ( listener . canChange ( state , order , ( ( String ) ( order . getStringField ( "state" ) ) ) ) ) ) { return ; } } if ( newState . getStringValue ( ) . equals ( COMPLETED . getStringValue ( ) ) ) { if ( ( checkAutogenealogyRequired ( ) ) && ( ! ( checkRequiredBatch ( order ) ) ) ) { state . addMessage ( translationService . translate ( "genealogies.message.batchNotFound" , state . getLocale ( ) ) , FAILURE , false ) ; return ; } if ( ( isQualityControlAutoCheckEnabled ( ) ) && ( ! ( checkIfAllQualityControlsAreClosed ( order ) ) ) ) { state . addMessage ( translationService . translate ( "qualityControls.qualityControls.not.closed" , state . getLocale ( ) ) , FAILURE , false ) ; return ; } } order . getDataDefinition ( ) . save ( order ) ; Entity orderFromDB = order . getDataDefinition ( ) . get ( order . getId ( ) ) ; if ( ! ( orderFromDB . getStringField ( "state" ) . equals ( newState . getStringValue ( ) ) ) ) { <START_BUG> for ( ErrorMessage message : order . getGlobalErrors ( ) ) { <END_BUG> StringBuilder error = new StringBuilder ( ) ; error = error . append ( translationService . translate ( "orders.order.orderStates.error" , state . getLocale ( ) ) ) ; error = error . append ( "<seq2seq4repair_space>" ) ; error = error . append ( orderFromDB . getStringField ( "name" ) ) ; error = error . append ( "<seq2seq4repair_space>" ) ; error = error . append ( message . getMessage ( ) ) ; state . addMessage ( error . toString ( ) , FAILURE , false ) ; } } } public void changeOrderStateToAcceptedForGrid ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } public void changeOrderStateToInProgressForGrid ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } public void changeOrderStateToCompletedForGrid ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } public void changeOrderStateToDeclinedForGrid ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } public void changeOrderStateToAbandonedForGrid ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } public void changeOrderStateToInterruptedForGrid ( final ViewDefinitionState viewDefinitionState , final ComponentState state , final String [ ] args ) { } private boolean hasIntegrationWithExternalSystem ( ) { } private boolean checkAutogenealogyRequired ( ) { } private boolean checkRequiredBatch ( final Entity entity ) { } private boolean isQualityControlAutoCheckEnabled ( ) { } private boolean checkIfAllQualityControlsAreClosed ( final Entity order ) { } public void registerBeforeChangeStateListener ( final OrderStatesService . BeforeChangeStateListener listener ) { } public static interface BeforeChangeStateListener { boolean canChange ( ComponentState gridOrForm , Entity order , String state ) { } } public void setFieldsRequired ( final ViewDefinitionState view ) { } }

Fix:
for ( ErrorMessage message : order . getErrors ( ) . values ( ) ) {