Buggy code:
class JobUpdateControllerImpl implements JobUpdateController { private static final Logger LOG = Logger . getLogger ( JobUpdateControllerImpl . class . getName ( ) ) ; private final UpdateFactory updateFactory ; private final LockManager lockManager ; private final Storage storage ; private final ScheduledExecutorService executor ; private final StateManager stateManager ; private final Clock clock ; private final JobUpdateControllerImpl . PulseHandler pulseHandler ; private final Map < JobKey , UpdateFactory . Update > updates = Collections . synchronizedMap ( Maps . newHashMap ( ) ) ; @ Inject JobUpdateControllerImpl ( UpdateFactory updateFactory , LockManager lockManager , Storage storage , ScheduledExecutorService executor , StateManager stateManager , Clock clock ) { } @ Override public void start ( final JobUpdate update , final AuditData auditData ) throws UpdateStateException { } @ Override public void pause ( final JobUpdateKey key , AuditData auditData ) throws UpdateStateException { } @ Override public void resume ( final JobUpdateKey key , final AuditData auditData ) throws UpdateStateException { } @ Override public void abort ( JobUpdateKey key , AuditData auditData ) throws UpdateStateException { } private static Function < JobUpdateStatus , JobUpdateEvent > createAuditedEvent ( final AuditData auditData ) { } @ Override public void systemResume ( ) { } @ Override public JobUpdatePulseStatus pulse ( final JobUpdateKey key ) throws UpdateStateException { } @ Override public void instanceChangedState ( final ScheduledTask updatedTask ) { } @ Override public void instanceDeleted ( InstanceKey instance ) { } private void instanceChanged ( final InstanceKey instance , final Optional < ScheduledTask > state ) { } private JobUpdateSummary getOnlyMatch ( JobUpdateStore store , JobUpdateQuery query ) { } @ VisibleForTesting static JobUpdateQuery queryActiveByJob ( JobKey job ) { } private void unscopedChangeUpdateStatus ( final JobUpdateKey key , final Function < ? super JobUpdateStatus , JobUpdateEvent > stateChange ) throws UpdateStateException { } private void changeUpdateStatus ( MutableStoreProvider storeProvider , JobUpdateSummary updateSummary , JobUpdateEvent event ) throws UpdateStateException { } private void recordAndChangeJobUpdateStatus ( MutableStoreProvider storeProvider , JobUpdateKey key , JobUpdateEvent event ) throws UpdateStateException { } private static final Set < JobUpdateStatus > TERMINAL_STATES = ImmutableSet . of ( ROLLED_FORWARD , ROLLED_BACK , ABORTED , FAILED , ERROR ) ; private void changeJobUpdateStatus ( MutableStoreProvider storeProvider , JobUpdateKey key , JobUpdateEvent proposedEvent , boolean recordChange ) throws UpdateStateException { JobUpdateStatus status ; boolean record ; JobUpdateStore . Mutable updateStore = storeProvider . getJobUpdateStore ( ) ; Optional < String > updateLock = updateStore . getLockToken ( key ) ; if ( updateLock . isPresent ( ) ) { status = proposedEvent . getStatus ( ) ; record = recordChange ; } else { JobUpdateControllerImpl . LOG . severe ( ( ( "Update<seq2seq4repair_space>" + key ) + "<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>have<seq2seq4repair_space>a<seq2seq4repair_space>lock" ) ) ; status = ERROR ; record = true ; } JobUpdateControllerImpl . LOG . info ( String . format ( "Update<seq2seq4repair_space>%s<seq2seq4repair_space>is<seq2seq4repair_space>now<seq2seq4repair_space>in<seq2seq4repair_space>state<seq2seq4repair_space>%s" , key , status ) ) ; if ( record ) { <START_BUG> updateStore . saveJobUpdateEvent ( key , JobUpdateEvent . builder ( ) . setTimestampMs ( clock . nowMillis ( ) ) . setStatus ( status ) . build ( ) ) ; <END_BUG> } if ( JobUpdateControllerImpl . TERMINAL_STATES . contains ( status ) ) { if ( updateLock . isPresent ( ) ) { lockManager . releaseLock ( Lock . builder ( ) . setKey ( LockKey . job ( key . getJob ( ) ) ) . setToken ( updateLock . get ( ) ) . build ( ) ) ; } pulseHandler . remove ( key ) ; } else { pulseHandler . updatePulseStatus ( key , status ) ; } JobUpdateStateMachine . MonitorAction action = JobUpdateStateMachine . getActionForStatus ( status ) ; JobKey job = key . getJob ( ) ; if ( action == ( MonitorAction . STOP_WATCHING ) ) { updates . remove ( job ) ; } else if ( ( action == ( MonitorAction . ROLL_FORWARD ) ) || ( action == ( MonitorAction . ROLL_BACK ) ) ) { if ( action == ( MonitorAction . ROLL_BACK ) ) { updates . remove ( job ) ; } else { Preconditions . checkState ( ( ! ( updates . containsKey ( job ) ) ) , ( "Updater<seq2seq4repair_space>already<seq2seq4repair_space>exists<seq2seq4repair_space>for<seq2seq4repair_space>" + job ) ) ; } JobUpdate jobUpdate = updateStore . fetchJobUpdate ( key ) . get ( ) ; UpdateFactory . Update update ; try { update = updateFactory . newUpdate ( jobUpdate . getInstructions ( ) , ( action == ( MonitorAction . ROLL_FORWARD ) ) ) ; } catch ( RuntimeException e ) { JobUpdateControllerImpl . LOG . log ( Level . WARNING , ( "Uncaught<seq2seq4repair_space>exception:<seq2seq4repair_space>" + e ) , e ) ; changeJobUpdateStatus ( storeProvider , key , JobUpdateControllerImpl . newEvent ( ERROR , ( "Internal<seq2seq4repair_space>scheduler<seq2seq4repair_space>error:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) ) , true ) ; return ; } updates . put ( job , update ) ; evaluateUpdater ( storeProvider , update , jobUpdate . getSummary ( ) , ImmutableMap . of ( ) ) ; } } private static Optional < ScheduledTask > getActiveInstance ( TaskStore taskStore , JobKey job , int instanceId ) { } private static final Set < SideEffect . InstanceUpdateStatus > NOOP_INSTANCE_UPDATE = ImmutableSet . of ( WORKING , SUCCEEDED ) ; private static boolean isCoordinatedUpdate ( JobUpdateInstructions instructions ) { } private boolean isCoordinatedAndPulseExpired ( JobUpdateKey key , JobUpdateInstructions instructions ) { } @ VisibleForTesting static final String LOST_LOCK_MESSAGE = "Updater<seq2seq4repair_space>has<seq2seq4repair_space>lost<seq2seq4repair_space>its<seq2seq4repair_space>exclusive<seq2seq4repair_space>lock,<seq2seq4repair_space>unable<seq2seq4repair_space>to<seq2seq4repair_space>proceed." ; @ VisibleForTesting static final String PULSE_TIMEOUT_MESSAGE = "Pulses<seq2seq4repair_space>from<seq2seq4repair_space>external<seq2seq4repair_space>service<seq2seq4repair_space>have<seq2seq4repair_space>timed<seq2seq4repair_space>out." ; private void evaluateUpdater ( final MutableStoreProvider storeProvider , final UpdateFactory . Update update , JobUpdateSummary summary , Map < Integer , Optional < ScheduledTask > > changedInstance ) throws UpdateStateException { } @ VisibleForTesting static final Function < JobInstanceUpdateEvent , JobUpdateAction > EVENT_TO_ACTION = new Function < JobInstanceUpdateEvent , JobUpdateAction > ( ) { @ Override public JobUpdateAction apply ( JobInstanceUpdateEvent event ) { } } ; @ VisibleForTesting static String failureMessage ( int instanceId , Failure failure ) { }

Fix:
updateStore . saveJobUpdateEvent ( key , proposedEvent . toBuilder ( ) . setTimestampMs ( clock . nowMillis ( ) ) . setStatus ( status ) . build ( ) ) ;