Buggy code:
public class ModelControllerImplUnitTestCase { private ServiceContainer container ; private ModelController controller ; private AtomicBoolean sharedState ; public static final void toggleRuntimeState ( AtomicBoolean state ) { } @ Before public void setupController ( ) throws InterruptedException { } @ After public void shutdownServiceContainer ( ) { } public static class ModelControllerService extends AbstractControllerService { final AtomicBoolean state = new AtomicBoolean ( true ) ; final CountDownLatch latch = new CountDownLatch ( 1 ) ; ModelControllerService ( final ControlledProcessState processState ) { } @ Override protected void initModel ( Resource rootResource , ManagementResourceRegistration rootRegistration ) { } @ Override public void start ( StartContext context ) throws StartException { } } @ Test public void testGoodModelExecution ( ) throws Exception { } @ Test public void testGoodModelExecutionTxRollback ( ) throws Exception { } @ Test public void testModelStageFailureExecution ( ) throws Exception { } @ Test public void testModelStageUnhandledFailureExecution ( ) throws Exception { } @ Test public void testHandleFailedExecution ( ) throws Exception { } @ Test public void testRuntimeStageFailedNoRollback ( ) throws Exception { } @ Test public void testRuntimeStageUnhandledFailureNoRollback ( ) throws Exception { } @ Test public void testOperationFailedExceptionNoRollback ( ) throws Exception { } @ Test public void testPathologicalRollback ( ) throws Exception { } @ Test public void testGoodService ( ) throws Exception { } @ Test public void testGoodServiceTxRollback ( ) throws Exception { } @ Test public void testBadService ( ) throws Exception { } @ Test public void testMissingService ( ) throws Exception { } @ Test public void testGlobal ( ) throws Exception { } public void testReloadRequired ( ) throws Exception { } @ Test public void testRestartRequired ( ) throws Exception { } @ Test public void testReloadRequiredTxRollback ( ) throws Exception { } @ Test public void testRestartRequiredTxRollback ( ) throws Exception { } public static ModelNode getOperation ( String opName , String attr , int val ) { } public static ModelNode getOperation ( String opName , String attr , int val , String rollbackName ) { } public static ModelNode getOperation ( String opName , String attr , int val , String rollbackName , boolean async ) { } public static class SetupHandler implements OperationStepHandler { @ Override public void execute ( OperationContext context , ModelNode operation ) { ModelNode model = new ModelNode ( ) ; model . get ( "attr1" ) . set ( 1 ) ; model . get ( "attr2" ) . set ( 2 ) ; <START_BUG> context . createResource ( EMPTY_ADDRESS ) . getModel ( ) . set ( model ) ; <END_BUG> final ModelNode child1 = new ModelNode ( ) ; child1 . get ( "attribute1" ) . set ( 1 ) ; final ModelNode child2 = new ModelNode ( ) ; child2 . get ( "attribute2" ) . set ( 2 ) ; context . createResource ( EMPTY_ADDRESS . append ( PathElement . pathElement ( "child" , "one" ) ) ) . getModel ( ) . set ( child1 ) ; context . createResource ( EMPTY_ADDRESS . append ( PathElement . pathElement ( "child" , "two" ) ) ) . getModel ( ) . set ( child2 ) ; context . completeStep ( ) ; } } public static class ModelStageGoodHandler implements OperationStepHandler { @ Override public void execute ( OperationContext context , ModelNode operation ) { String name = operation . require ( NAME ) . asString ( ) ; ModelNode model = context . readModelForUpdate ( EMPTY_ADDRESS ) ; ModelNode attr = model . get ( name ) ; final int current = attr . asInt ( ) ; attr . set ( operation . require ( VALUE ) ) ; context . getResult ( ) . set ( current ) ; context . completeStep ( ) ; } } public static class ModelStageFailsHandler implements OperationStepHandler { @ Override public void execute ( OperationContext context , ModelNode operation ) { String name = operation . require ( NAME ) . asString ( ) ; ModelNode model = context . readModelForUpdate ( EMPTY_ADDRESS ) ; ModelNode attr = model . get ( name ) ; attr . set ( operation . require ( VALUE ) ) ; context . getFailureDescription ( ) . set ( "this<seq2seq4repair_space>request<seq2seq4repair_space>is<seq2seq4repair_space>bad" ) ; context . completeStep ( ) ; } } public static class ModelStageThrowsExceptionHandler implements OperationStepHandler { @ Override public void execute ( OperationContext context , ModelNode operation ) { String name = operation . require ( NAME ) . asString ( ) ; ModelNode model = context . readModelForUpdate ( EMPTY_ADDRESS ) ; ModelNode attr = model . get ( name ) ; attr . set ( operation . require ( VALUE ) ) ; throw new RuntimeException ( "this<seq2seq4repair_space>handler<seq2seq4repair_space>is<seq2seq4repair_space>evil" ) ; } } public static class RuntimeStageFailsHandler implements OperationStepHandler { private final AtomicBoolean state ; public RuntimeStageFailsHandler ( AtomicBoolean state ) { } @ Override public void execute ( OperationContext context , ModelNode operation ) { String name = operation . require ( "name" ) . asString ( ) ; ModelNode attr = context . readModelForUpdate ( EMPTY_ADDRESS ) . get ( name ) ; int current = attr . asInt ( ) ; attr . set ( operation . require ( "value" ) ) ; context . getResult ( ) . set ( current ) ; context . addStep ( new OperationStepHandler ( ) { @ Override public void execute ( OperationContext context , ModelNode operation ) { ModelControllerImplUnitTestCase . toggleRuntimeState ( state ) ; context . getFailureDescription ( ) . set ( "handleFailed" ) ; if ( ( context . completeStep ( ) ) == ( ResultAction . ROLLBACK ) ) { ModelControllerImplUnitTestCase . toggleRuntimeState ( state ) ; } } } , RUNTIME ) ; context . completeStep ( ) ; } } public static class RuntimeStageThrowsExceptionHandler implements OperationStepHandler { private final AtomicBoolean state ; public RuntimeStageThrowsExceptionHandler ( AtomicBoolean state ) { }

Fix:
context . readResourceForUpdate ( EMPTY_ADDRESS ) . getModel ( ) . set ( model ) ;