Buggy code:
final class NewOperationContextImpl implements NewOperationContext { private final NewModelControllerImpl modelController ; private final Type contextType ; private final EnumSet < NewOperationContextImpl . ContextFlag > contextFlags ; private final OperationMessageHandler messageHandler ; private final Thread initiatingThread ; private final EnumMap < Stage , Deque < NewOperationContextImpl . Step > > steps ; private final OperationTransactionControl transactionControl ; private final ServiceTarget serviceTarget ; private final Map < ServiceName , ServiceController < ? > > realRemovingControllers = new HashMap < ServiceName , ServiceController < ? > > ( ) ; private final boolean booting ; private boolean respectInterruption = true ; private PathAddress modelAddress ; private Stage currentStage = Stage . MODEL ; private EnumSet < NewOperationContextImpl . Flag > flags = EnumSet . noneOf ( NewOperationContextImpl . Flag . class ) ; private ModelNode response ; private ModelNode operation ; private ModelNode model ; private ModelNode readOnlyModel ; private ResultAction resultAction ; enum ContextFlag { ROLLBACK_ON_FAIL ; } enum Flag { AFFECTS_MODEL , AFFECTS_RUNTIME , WRITE_LOCK_TAKEN , CANCELLED ; } NewOperationContextImpl ( final NewModelControllerImpl modelController , final Type contextType , final EnumSet < NewOperationContextImpl . ContextFlag > contextFlags , final OperationMessageHandler messageHandler , final ModelNode model , final NewModelController . OperationTransactionControl transactionControl , final boolean booting ) { } public InputStream getAttachmentStream ( final int index ) throws IOException { } public void addStep ( final NewStepHandler step , final Stage stage ) throws IllegalArgumentException { } public void addStep ( final ModelNode response , final ModelNode operation , final NewStepHandler step , final Stage stage ) throws IllegalArgumentException { assert ( Thread . currentThread ( ) ) == ( initiatingThread ) ; if ( response == null ) { throw new IllegalArgumentException ( "response<seq2seq4repair_space>is<seq2seq4repair_space>null" ) ; } if ( operation == null ) { throw new IllegalArgumentException ( "operation<seq2seq4repair_space>is<seq2seq4repair_space>null" ) ; } if ( step == null ) { throw new IllegalArgumentException ( "step<seq2seq4repair_space>is<seq2seq4repair_space>null" ) ; } if ( stage == null ) { throw new IllegalArgumentException ( "stage<seq2seq4repair_space>is<seq2seq4repair_space>null" ) ; } if ( ( currentStage ) == ( Stage . DONE ) ) { throw new IllegalStateException ( "Operation<seq2seq4repair_space>already<seq2seq4repair_space>complete" ) ; } <START_BUG> if ( ( stage . compareTo ( currentStage ) ) > 0 ) { <END_BUG> throw new IllegalStateException ( ( ( "Stage<seq2seq4repair_space>" + stage ) + "<seq2seq4repair_space>is<seq2seq4repair_space>already<seq2seq4repair_space>complete" ) ) ; } if ( ( ( contextType ) == ( Type . MANAGEMENT ) ) && ( ( stage . compareTo ( MODEL ) ) > 0 ) ) { throw new IllegalArgumentException ( "Invalid<seq2seq4repair_space>step<seq2seq4repair_space>stage<seq2seq4repair_space>for<seq2seq4repair_space>this<seq2seq4repair_space>context<seq2seq4repair_space>type" ) ; } if ( stage == ( Stage . DONE ) ) { throw new IllegalArgumentException ( "Invalid<seq2seq4repair_space>step<seq2seq4repair_space>stage<seq2seq4repair_space>specified" ) ; } if ( stage == ( Stage . IMMEDIATE ) ) { steps . get ( currentStage ) . addFirst ( new NewOperationContextImpl . Step ( step , response , operation ) ) ; } else { steps . get ( stage ) . addLast ( new NewOperationContextImpl . Step ( step , response , operation ) ) ; } } public ModelNode getFailureDescription ( ) { } public ResultAction completeStep ( ) { } private ResultAction doCompleteStep ( ) { } public Type getType ( ) { } public boolean isBooting ( ) { } public boolean isRollbackOnly ( ) { } public void setRollbackOnly ( ) { } public ModelNodeRegistration getModelNodeRegistration ( ) { } public ServiceRegistry getServiceRegistry ( final boolean modify ) throws UnsupportedOperationException { } public ServiceController < ? > removeService ( final ServiceName name ) throws UnsupportedOperationException { } public void removeService ( final ServiceController < ? > controller ) throws UnsupportedOperationException { } private void doRemove ( final ServiceController < ? > controller ) { } public ServiceTarget getServiceTarget ( ) throws UnsupportedOperationException { } private void takeWriteLock ( ) { } public ModelNode readModel ( final PathAddress requestAddress ) { } public ModelNode readModelForUpdate ( final PathAddress requestAddress ) { } public ModelNode getModel ( ) { } public ModelNode writeModel ( final PathAddress requestAddress , final ModelNode newData ) throws UnsupportedOperationException { } public ModelNode removeModel ( final PathAddress requestAddress ) throws UnsupportedOperationException { } public boolean isModelAffected ( ) { } public boolean isRuntimeAffected ( ) { } public Stage getCurrentStage ( ) { } public ModelNode getCompensatingOperation ( ) { } public void report ( final MessageSeverity severity , final String message ) { } public ModelNode getResult ( ) { } static class Step { private final NewStepHandler handler ; private final ModelNode response ; private final ModelNode operation ; private Step ( final NewStepHandler handler , final ModelNode response , final ModelNode operation ) { } } class ContextServiceTarget implements ServiceTarget { private final NewModelControllerImpl modelController ; ContextServiceTarget ( final NewModelControllerImpl modelController ) { } public < T > ServiceBuilder < T > addServiceValue ( final ServiceName name , final Value < ? extends Service < T > > value ) { } public < T > ServiceBuilder < T > addService ( final ServiceName name , final Service < T > service ) { } public ServiceTarget addListener ( final ServiceListener < Object > listener ) { } public ServiceTarget addListener ( final ServiceListener < Object > ... listeners ) { } public ServiceTarget addListener ( final Collection < ServiceListener < Object > > listeners ) { } public ServiceTarget removeListener ( final ServiceListener < Object > listener ) { } public Set < ServiceListener < Object > > getListeners ( ) { } public ServiceTarget addDependency ( final ServiceName dependency ) { } public ServiceTarget addDependency ( final ServiceName ... dependencies ) { } public ServiceTarget addDependency ( final Collection < ServiceName > dependencies ) { } public ServiceTarget removeDependency ( final ServiceName dependency ) { } public Set < ServiceName > getDependencies ( ) { } public ServiceTarget subTarget ( ) { } public BatchServiceTarget batchTarget ( ) { } } class ContextServiceBuilder < T > implements ServiceBuilder < T > { private final ServiceBuilder < T > realBuilder ; private final ServiceName name ;

Fix:
if ( ( stage . compareTo ( currentStage ) ) < 0 ) {