Program: 8887
Project: 8887
Buggy source:
/** 
 * Finds a matching definition for a property with the given name and type.
 * @param property modified property
 * @return matching property definition, or {@code null}
 */
@CheckForNull NodeState getDefinition(PropertyState property){
  String propertyName=property.getName();
  Type<?> propertyType=property.getType();
  String escapedName;
  if (JCR_PRIMARYTYPE.equals(propertyName)) {
    escapedName=NodeTypeConstants.REP_PRIMARY_TYPE;
  }
 else   if (JCR_MIXINTYPES.equals(propertyName)) {
    escapedName=NodeTypeConstants.REP_MIXIN_TYPES;
  }
 else   if (JCR_UUID.equals(propertyName)) {
    escapedName=NodeTypeConstants.REP_UUID;
  }
 else {
    escapedName=propertyName;
  }
  String definedType=propertyType.toString();
  String undefinedType;
  if (propertyType.isArray()) {
    undefinedType=UNDEFINEDS.toString();
  }
 else {
    undefinedType=UNDEFINED.toString();
  }
  for (  NodeState type : types) {
    NodeState definitions=type.getChildNode(REP_NAMED_PROPERTY_DEFINITIONS).getChildNode(escapedName);
    NodeState definition=definitions.getChildNode(definedType);
    if (definition.exists()) {
      return definition;
    }
    definition=definitions.getChildNode(undefinedType);
    if (definition.exists()) {
      return definition;
    }
    for (    ChildNodeEntry entry : definitions.getChildNodeEntries()) {
      definition=entry.getNodeState();
      if (definition.getBoolean(JCR_MANDATORY)) {
        return definition;
      }
    }
  }
  for (  NodeState type : types) {
    NodeState residual=type.getChildNode(REP_RESIDUAL_PROPERTY_DEFINITIONS);
    NodeState definition=residual.getChildNode(definedType);
    if (!definition.exists()) {
      definition=residual.getChildNode(undefinedType);
    }
    if (definition.exists()) {
      return definition;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Finds a matching definition for a property with the given name and type.
 * @param property modified property
 * @return matching property definition, or {@code null}
 */
@CheckForNull NodeState getDefinition(@Nonnull PropertyState property){
  String propertyName=property.getName();
  Type<?> propertyType=property.getType();
  String escapedName;
  if (JCR_PRIMARYTYPE.equals(propertyName)) {
    escapedName=NodeTypeConstants.REP_PRIMARY_TYPE;
  }
 else   if (JCR_MIXINTYPES.equals(propertyName)) {
    escapedName=NodeTypeConstants.REP_MIXIN_TYPES;
  }
 else   if (JCR_UUID.equals(propertyName)) {
    escapedName=NodeTypeConstants.REP_UUID;
  }
 else {
    escapedName=propertyName;
  }
  String definedType=propertyType.toString();
  String undefinedType;
  if (propertyType.isArray()) {
    undefinedType=UNDEFINEDS.toString();
  }
 else {
    undefinedType=UNDEFINED.toString();
  }
  for (  NodeState type : types) {
    NodeState definitions=type.getChildNode(REP_NAMED_PROPERTY_DEFINITIONS).getChildNode(escapedName);
    NodeState definition=definitions.getChildNode(definedType);
    if (definition.exists()) {
      return definition;
    }
    definition=definitions.getChildNode(undefinedType);
    if (definition.exists()) {
      return definition;
    }
    for (    ChildNodeEntry entry : definitions.getChildNodeEntries()) {
      definition=entry.getNodeState();
      if (definition.getBoolean(JCR_MANDATORY)) {
        return definition;
      }
    }
  }
  for (  NodeState type : types) {
    NodeState residual=type.getChildNode(REP_RESIDUAL_PROPERTY_DEFINITIONS);
    NodeState definition=residual.getChildNode(definedType);
    if (!definition.exists()) {
      definition=residual.getChildNode(undefinedType);
    }
    if (definition.exists()) {
      return definition;
    }
  }
  return null;
}