Buggy code:
final class OperationContextImpl implements OperationContext { private static final Logger log = Logger . getLogger ( "org.jboss.as.controller" ) ; private final ModelControllerImpl modelController ; private final Type contextType ; private final EnumSet < OperationContextImpl . ContextFlag > contextFlags ; private final OperationMessageHandler messageHandler ; private final Thread initiatingThread ; private final EnumMap < Stage , Deque < OperationContextImpl . 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 final OperationAttachments attachments ; private final ControlledProcessState processState ; private final Set < PathAddress > affectsModel ; private boolean affectsResourceRegistration ; private boolean respectInterruption = true ; private PathAddress modelAddress ; private Stage currentStage = Stage . MODEL ; private ModelNode response ; private ModelNode operation ; private Resource model ; private ResultAction resultAction ; private boolean affectsRuntime ; private boolean cancelled ; private int depth ; private int lockDepth ; private int containerMonitorDepth ; private OperationContextImpl . StampHolder restartStampHolder ; enum ContextFlag { ROLLBACK_ON_FAIL , ALLOW_RESOURCE_SERVICE_RESTART ; } OperationContextImpl ( final ModelControllerImpl modelController , final Type contextType , final EnumSet < OperationContextImpl . ContextFlag > contextFlags , final OperationMessageHandler messageHandler , final OperationAttachments attachments , final Resource model , final ModelController . OperationTransactionControl transactionControl , final ControlledProcessState processState , final boolean booting ) { } public InputStream getAttachmentStream ( final int index ) { } public int getAttachmentStreamCount ( ) { } 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 { } public ModelNode getFailureDescription ( ) { } public boolean hasFailureDescription ( ) { } public ResultAction completeStep ( ) { } private ResultAction doCompleteStep ( ) { } private ResultAction executeStep ( final OperationContextImpl . Step step ) { } private ResultAction getFailedResultAction ( Throwable cause ) { } public Type getType ( ) { } public boolean isBooting ( ) { } public boolean isRollbackOnly ( ) { } public void setRollbackOnly ( ) { } private boolean isRollingBack ( ) { } @ Override public boolean isRollbackOnRuntimeFailure ( ) { } @ Override public boolean isResourceServiceRestartAllowed ( ) { } @ Override public void reloadRequired ( ) { } @ Override public void restartRequired ( ) { } @ Override public void revertReloadRequired ( ) { } @ Override public void revertRestartRequired ( ) { } @ Override public void runtimeUpdateSkipped ( ) { } public ManagementResourceRegistration getResourceRegistrationForUpdate ( ) { } public ImmutableManagementResourceRegistration getResourceRegistration ( ) { } public ServiceRegistry getServiceRegistry ( final boolean modify ) throws UnsupportedOperationException { assert ( Thread . currentThread ( ) ) == ( initiatingThread ) ; Stage currentStage = this . currentStage ; if ( currentStage == null ) { throw new IllegalStateException ( "Operation<seq2seq4repair_space>already<seq2seq4repair_space>complete" ) ; } <START_BUG> if ( ! ( ( ( currentStage == ( Stage . RUNTIME ) ) || ( currentStage == ( Stage . VERIFY ) ) ) || ( ( isRollingBack ( ) ) && ( ! modify ) ) ) ) { <END_BUG> throw new IllegalStateException ( "Get<seq2seq4repair_space>service<seq2seq4repair_space>registry<seq2seq4repair_space>only<seq2seq4repair_space>supported<seq2seq4repair_space>in<seq2seq4repair_space>runtime<seq2seq4repair_space>operations" ) ; } if ( modify && ( ! ( affectsRuntime ) ) ) { takeWriteLock ( ) ; affectsRuntime = true ; acquireContainerMonitor ( ) ; awaitContainerMonitor ( ) ; } return modelController . getServiceRegistry ( ) ; } 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 ( ) { } private void acquireContainerMonitor ( ) { } private void awaitContainerMonitor ( ) { } public ModelNode readModel ( final PathAddress requestAddress ) { } public ModelNode readModelForUpdate ( final PathAddress requestAddress ) { } public Resource readResource ( PathAddress requestAddress ) { } public Resource readResourceForUpdate ( PathAddress requestAddress ) { } public Resource createResource ( PathAddress relativeAddress ) { } public void addResource ( PathAddress relativeAddress , Resource toAdd ) { } public Resource removeResource ( final PathAddress requestAddress ) { } public void acquireControllerLock ( ) { } public Resource getRootResource ( ) { } public boolean isModelAffected ( ) { } public boolean isRuntimeAffected ( ) { } public boolean isResourceRegistryAffected ( ) { } public Stage getCurrentStage ( ) { } public void report ( final MessageSeverity severity , final String message ) { } public ModelNode getResult ( ) { } public boolean hasResult ( ) { } static class Step { private final OperationStepHandler handler ; private final ModelNode response ; private final ModelNode operation ; private final OperationContextImpl . StampHolder restartStamp = new OperationContextImpl . StampHolder ( ) ; private Step ( final OperationStepHandler handler , final ModelNode response , final ModelNode operation ) { } } static class StampHolder { private Object restartStamp ; } class ContextServiceTarget implements ServiceTarget { private final ModelControllerImpl modelController ; ContextServiceTarget ( final ModelControllerImpl 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 ) { }

Fix:
if ( ! ( ( ( ( currentStage == ( Stage . RUNTIME ) ) || ( currentStage == ( Stage . MODEL ) ) ) || ( currentStage == ( Stage . VERIFY ) ) ) || ( ( isRollingBack ( ) ) && ( ! modify ) ) ) ) {