Buggy code:
public class ModelTestUtils { private static final Pattern EXPRESSION_PATTERN = Pattern . compile ( ".*\\$\\{.*\\}.*" ) ; public static String readResource ( final Class < ? > clazz , final String name ) throws IOException { } public static ModelNode checkResultAndGetContents ( ModelNode result ) { } public static ModelNode checkOutcome ( ModelNode result ) { } public static ModelNode checkFailed ( ModelNode result ) { } public static void validateModelDescriptions ( PathAddress address , ImmutableManagementResourceRegistration reg ) { } public static void compare ( ModelNode node1 , ModelNode node2 ) { } public static void resolveAndCompareModels ( ModelNode node1 , ModelNode node2 ) { } public static void compare ( ModelNode node1 , ModelNode node2 , boolean ignoreUndefined ) { } public static String normalizeXML ( String xml ) throws Exception { } public static void compareXml ( final String original , final String marshalled ) throws Exception { } public static void compareXml ( final String original , final String marshalled , final boolean ignoreNamespace ) throws Exception { } public static ModelNode getSubModel ( ModelNode model , PathElement pathElement ) { } public static ModelNode getSubModel ( ModelNode model , PathAddress pathAddress ) { } public static void scanForExpressionFormattedStrings ( ModelNode model ) { } private static String removeNamespace ( String xml ) { } private static void compare ( ModelNode node1 , ModelNode node2 , boolean ignoreUndefined , boolean ignoreType , Stack < String > stack ) { } private static ModelNode trimUndefinedChildren ( ModelNode model ) { } private static String getCompareStackAsString ( Stack < String > stack ) { } public static void checkModelAgainstDefinition ( final ModelNode model , ManagementResourceRegistration rr ) { } private static void checkModelAgainstDefinition ( final ModelNode model , ManagementResourceRegistration rr , Stack < PathElement > stack ) { final Set < String > children = rr . getChildNames ( EMPTY_ADDRESS ) ; final Set < String > attributeNames = rr . getAttributeNames ( EMPTY_ADDRESS ) ; for ( ModelNode el : model . asList ( ) ) { String name = el . asProperty ( ) . getName ( ) ; ModelNode value = el . asProperty ( ) . getValue ( ) ; if ( attributeNames . contains ( name ) ) { AttributeAccess aa = rr . getAttributeAccess ( EMPTY_ADDRESS , name ) ; Assert . assertNotNull ( ( ( ( ( ModelTestUtils . getComparePathAsString ( stack ) ) + "<seq2seq4repair_space>Attribute<seq2seq4repair_space>" ) + name ) + "<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>known" ) , aa ) ; AttributeDefinition ad = aa . getAttributeDefinition ( ) ; if ( ! ( value . isDefined ( ) ) ) { Assert . assertTrue ( ( ( ( ( ModelTestUtils . getComparePathAsString ( stack ) ) + "<seq2seq4repair_space>Attribute<seq2seq4repair_space>" ) + name ) + "<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>allow<seq2seq4repair_space>null" ) , ad . isAllowNull ( ) ) ; } else { } try { if ( ( ! ( ad . isAllowNull ( ) ) ) && ( value . isDefined ( ) ) ) { ad . getValidator ( ) . validateParameter ( name , value ) ; } } catch ( OperationFailedException e ) { Assert . fail ( ( ( ( ( ( ModelTestUtils . getComparePathAsString ( stack ) ) + "<seq2seq4repair_space>validation<seq2seq4repair_space>for<seq2seq4repair_space>attribute<seq2seq4repair_space>'" ) + name ) + "'<seq2seq4repair_space>failed,<seq2seq4repair_space>" ) + ( e . getFailureDescription ( ) . asString ( ) ) ) ) ; } } else if ( ! ( children . contains ( name ) ) ) { Assert . fail ( ( ( ( ( ModelTestUtils . getComparePathAsString ( stack ) ) + "<seq2seq4repair_space>Element<seq2seq4repair_space>'" ) + name ) + "'<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>known<seq2seq4repair_space>in<seq2seq4repair_space>target<seq2seq4repair_space>definition" ) ) ; } } for ( PathElement pe : rr . getChildAddresses ( EMPTY_ADDRESS ) ) { if ( pe . isWildcard ( ) ) { if ( ( children . contains ( pe . getKey ( ) ) ) && ( model . hasDefined ( pe . getKey ( ) ) ) ) { for ( ModelNode v : model . get ( pe . getKey ( ) ) . asList ( ) ) { String name = v . asProperty ( ) . getName ( ) ; ModelNode value = v . asProperty ( ) . getValue ( ) ; ManagementResourceRegistration sub = rr . getSubModel ( PathAddress . pathAddress ( pe ) ) ; Assert . assertNotNull ( ( ( ( ( ModelTestUtils . getComparePathAsString ( stack ) ) + "<seq2seq4repair_space>Child<seq2seq4repair_space>with<seq2seq4repair_space>name<seq2seq4repair_space>'" ) + name ) + "'<seq2seq4repair_space>not<seq2seq4repair_space>found" ) , sub ) ; if ( value . isDefined ( ) ) { stack . push ( pe ) ; ModelTestUtils . checkModelAgainstDefinition ( value , sub , stack ) ; stack . pop ( ) ; } } } } else { <START_BUG> if ( children . contains ( pe . getKeyValuePair ( ) ) ) { <END_BUG> String name = pe . getValue ( ) ; ModelNode value = model . get ( pe . getKeyValuePair ( ) ) ; ManagementResourceRegistration sub = rr . getSubModel ( PathAddress . pathAddress ( pe ) ) ; Assert . assertNotNull ( ( ( ( ( ModelTestUtils . getComparePathAsString ( stack ) ) + "<seq2seq4repair_space>Child<seq2seq4repair_space>with<seq2seq4repair_space>name<seq2seq4repair_space>'" ) + name ) + "'<seq2seq4repair_space>not<seq2seq4repair_space>found" ) , sub ) ; if ( value . isDefined ( ) ) { stack . push ( pe ) ; ModelTestUtils . checkModelAgainstDefinition ( value , sub , stack ) ; stack . pop ( ) ; } } } } } private static String getComparePathAsString ( Stack < PathElement > stack ) { } public static void checkFailedTransformedBootOperations ( ModelTestKernelServices < ? > mainServices , ModelVersion modelVersion , List < ModelNode > operations , FailedOperationTransformationConfig config ) throws OperationFailedException { } private static void checkFailedTransformedAddOperation ( ModelTestKernelServices < ? > mainServices , ModelVersion modelVersion , ModelNode operation , FailedOperationTransformationConfig config ) throws OperationFailedException { } private static void checkFailedTransformedWriteAttributeOperation ( ModelTestKernelServices < ? > mainServices , ModelVersion modelVersion , ModelNode operation , FailedOperationTransformationConfig config ) throws OperationFailedException { } }

Fix:
if ( ( ( children . contains ( pe . getKey ( ) ) ) && ( model . hasDefined ( pe . getKey ( ) ) ) ) && ( model . get ( pe . getKey ( ) ) . hasDefined ( pe . getValue ( ) ) ) ) {