Buggy code:
abstract class AbstractOperationContext implements OperationContext { static final Logger log = Logger . getLogger ( "org.jboss.as.controller" ) ; static final ThreadLocal < Thread > controllingThread = new ThreadLocal < Thread > ( ) ; private final Type contextType ; private final Thread initiatingThread ; private final EnumMap < Stage , Deque < AbstractOperationContext . Step > > steps ; private final OperationTransactionControl transactionControl ; private final ControlledProcessState processState ; boolean respectInterruption = true ; Stage currentStage = Stage . MODEL ; ResultAction resultAction ; private boolean cancelled ; AbstractOperationContext . Step activeStep ; enum ContextFlag { ROLLBACK_ON_FAIL , ALLOW_RESOURCE_SERVICE_RESTART ; } AbstractOperationContext ( final Type contextType , final ModelController . OperationTransactionControl transactionControl , final ControlledProcessState processState ) { } public void addStep ( final OperationStepHandler step , final Stage stage ) throws IllegalArgumentException { } public void addStep ( final ModelNode operation , final OperationStepHandler step , final Stage stage ) throws IllegalArgumentException { } public void addStep ( final ModelNode response , final ModelNode operation , final OperationStepHandler step , final Stage stage ) throws IllegalArgumentException { } void addStep ( final ModelNode response , final ModelNode operation , final PathAddress address , final OperationStepHandler step , final Stage stage ) throws IllegalArgumentException { <START_BUG> assert ( Thread . currentThread ( ) ) == ( initiatingThread ) ; <END_BUG> 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" ) ; } if ( ( ( stage . compareTo ( currentStage ) ) < 0 ) && ( ( stage != ( Stage . IMMEDIATE ) ) || ( ( currentStage ) == ( Stage . DONE ) ) ) ) { throw new IllegalStateException ( ( ( "Stage<seq2seq4repair_space>" + stage ) + "<seq2seq4repair_space>is<seq2seq4repair_space>already<seq2seq4repair_space>complete" ) ) ; } if ( ( ( contextType ) == ( Type . MANAGEMENT ) ) && ( ( stage . compareTo ( MODEL ) ) > 0 ) ) { if ( stage != ( Stage . VERIFY ) ) { 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 . DOMAIN ) ) && ( ( contextType ) != ( Type . HOST ) ) ) { throw new IllegalStateException ( ( ( ( "Stage<seq2seq4repair_space>" + stage ) + "<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>valid<seq2seq4repair_space>for<seq2seq4repair_space>context<seq2seq4repair_space>type<seq2seq4repair_space>" ) + ( contextType ) ) ) ; } 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 AbstractOperationContext . Step ( step , response , operation , address ) ) ; } else { steps . get ( stage ) . addLast ( new AbstractOperationContext . Step ( step , response , operation , address ) ) ; } } public final ModelNode getFailureDescription ( ) { } public final boolean hasFailureDescription ( ) { } public final ResultAction completeStep ( ) { } public final void completeStep ( RollbackHandler rollbackHandler ) { } private void doCompleteStep ( ) { } abstract void awaitModelControllerContainerMonitor ( ) throws InterruptedException { } abstract PersistenceResource createPersistenceResource ( ) throws ConfigurationPersistenceException { } private boolean canContinueProcessing ( ) { } private void executeStep ( final AbstractOperationContext . Step step ) { } private ResultAction getFailedResultAction ( Throwable cause ) { } public final Type getType ( ) { } public final boolean isRollbackOnly ( ) { } public final void setRollbackOnly ( ) { } final boolean isRollingBack ( ) { } @ Override public final void reloadRequired ( ) { } @ Override public final void restartRequired ( ) { } @ Override public final void revertReloadRequired ( ) { } @ Override public final void revertRestartRequired ( ) { } @ Override public final void runtimeUpdateSkipped ( ) { } public final ModelNode getResult ( ) { } public final boolean hasResult ( ) { } private boolean hasMoreSteps ( ) { } boolean isControllingThread ( ) { } abstract void releaseStepLocks ( AbstractOperationContext . Step step ) { } class Step { private final OperationStepHandler handler ; final ModelNode response ; final ModelNode operation ; final PathAddress address ; private Object restartStamp ; private RollbackHandler rollbackHandler ; private AbstractOperationContext . Step predecessor ; private Step ( final OperationStepHandler handler , final ModelNode response , final ModelNode operation , final PathAddress address ) { } private void finalizeStep ( ) { } private void finalizeInternal ( ) { } private void handleRollback ( ) { } } }

Fix:
assert isControllingThread ( ) ;