Program: 59417
Project: 59417
Buggy source:
/** 
 * Return an instance of the Metadata offered by this add-on.
 */
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata(String mid,JavaType aspect,PhysicalTypeMetadata controllerMetadata,String file){
  WebScaffoldAnnotationValues webScaffoldAnnotationValues=new WebScaffoldAnnotationValues(controllerMetadata);
  if (!webScaffoldAnnotationValues.isAnnotationFound() || webScaffoldAnnotationValues.getFormBackingObject() == null || controllerMetadata.getMemberHoldingTypeDetails() == null) {
    return null;
  }
  JavaType controllerType=PatternMetadata.getJavaType(mid);
  LogicalPath path=PatternMetadata.getPath(mid);
  String webScaffoldMetadataId=WebScaffoldMetadata.createIdentifier(controllerType,path);
  WebScaffoldMetadata webScaffoldMetadata=(WebScaffoldMetadata)metadataService.get(webScaffoldMetadataId);
  if (webScaffoldMetadata == null) {
    return null;
  }
  ClassOrInterfaceTypeDetails controllerTypeDetails=(ClassOrInterfaceTypeDetails)controllerMetadata.getMemberHoldingTypeDetails();
  Validate.notNull(controllerTypeDetails,"String_Node_Str");
  Validate.isTrue(!patternService.isPatternDuplicated(null),"String_Node_Str");
  List<StringAttributeValue> patternList=patternService.getPatternAttributes(controllerType);
  JavaType entity=webScaffoldAnnotationValues.getFormBackingObject();
  PhysicalTypeMetadata entityMetadata=(PhysicalTypeMetadata)metadataService.get(PhysicalTypeIdentifier.createIdentifier(entity,LogicalPath.getInstance(Path.SRC_MAIN_JAVA,"String_Node_Str")));
  Validate.notNull(entityMetadata,"String_Node_Str" + entity.getFullyQualifiedTypeName());
  MemberDetails entityDetails=getMemberDetails(entityMetadata);
  MemberHoldingTypeDetails entityPersistentDetails=MemberFindingUtils.getMostConcreteMemberHoldingTypeDetailsWithTag(entityDetails,CustomDataKeys.PERSISTENT_TYPE);
  SortedMap<JavaType,JavaTypeMetadataDetails> relatedEntities=webMetadataService.getRelatedApplicationTypeMetadata(entity,entityDetails,mid);
  if (entityPersistentDetails == null || relatedEntities == null || relatedEntities.get(entity) == null || relatedEntities.get(entity).getPersistenceDetails() == null) {
    return null;
  }
  JavaType oldEntity=webScaffoldMidToEntityMap.get(mid);
  if (oldEntity != null) {
    entityToWebScaffoldMidMap.remove(oldEntity);
  }
  entityToWebScaffoldMidMap.put(entity,mid);
  webScaffoldMidToEntityMap.put(mid,entity);
  MemberDetails controllerDetails=getMemberDetails(controllerMetadata);
  Map<JavaSymbolName,DateTimeFormatDetails> entityDateTypes=webMetadataService.getDatePatterns(entity,entityDetails,mid);
  OperationUtils.installWebDialogClass(aspect.getPackage().getFullyQualifiedPackageName().concat("String_Node_Str"),projectOperations.getPathResolver(),fileManager);
  SortedMap<JavaType,JavaTypeMetadataDetails> relatedFields=getRelationFieldsDetails(mid,controllerMetadata,entity,webMetadataService);
  Map<JavaType,Map<JavaSymbolName,DateTimeFormatDetails>> relatedDates=getRelationFieldsDateFormat(mid,controllerMetadata,entity,webMetadataService);
  return new PatternMetadata(mid,aspect,controllerMetadata,controllerDetails,webScaffoldMetadata,patternList,entityMetadata,relatedEntities,relatedFields,relatedDates,entityDateTypes);
}

Fixed version (ground truth):
/** 
 * Return an instance of the Metadata offered by this add-on.
 */
@Override protected ItdTypeDetailsProvidingMetadataItem getMetadata(String mid,JavaType aspect,PhysicalTypeMetadata controllerMetadata,String file){
  WebScaffoldAnnotationValues webScaffoldAnnotationValues=new WebScaffoldAnnotationValues(controllerMetadata);
  if (!webScaffoldAnnotationValues.isAnnotationFound() || webScaffoldAnnotationValues.getFormBackingObject() == null || controllerMetadata.getMemberHoldingTypeDetails() == null) {
    return null;
  }
  JavaType controllerType=PatternMetadata.getJavaType(mid);
  LogicalPath path=PatternMetadata.getPath(mid);
  String webScaffoldMetadataId=WebScaffoldMetadata.createIdentifier(controllerType,path);
  WebScaffoldMetadata webScaffoldMetadata=(WebScaffoldMetadata)metadataService.get(webScaffoldMetadataId);
  if (webScaffoldMetadata == null) {
    return null;
  }
  ClassOrInterfaceTypeDetails controllerTypeDetails=(ClassOrInterfaceTypeDetails)controllerMetadata.getMemberHoldingTypeDetails();
  Validate.notNull(controllerTypeDetails,"String_Node_Str");
  Validate.isTrue(!patternService.existsMasterPatternDuplicated(),"String_Node_Str");
  List<StringAttributeValue> patternList=patternService.getControllerMasterPattern(controllerType);
  JavaType entity=webScaffoldAnnotationValues.getFormBackingObject();
  PhysicalTypeMetadata entityMetadata=(PhysicalTypeMetadata)metadataService.get(PhysicalTypeIdentifier.createIdentifier(entity,LogicalPath.getInstance(Path.SRC_MAIN_JAVA,"String_Node_Str")));
  Validate.notNull(entityMetadata,"String_Node_Str" + entity.getFullyQualifiedTypeName());
  MemberDetails entityDetails=getMemberDetails(entityMetadata);
  MemberHoldingTypeDetails entityPersistentDetails=MemberFindingUtils.getMostConcreteMemberHoldingTypeDetailsWithTag(entityDetails,CustomDataKeys.PERSISTENT_TYPE);
  SortedMap<JavaType,JavaTypeMetadataDetails> relatedEntities=webMetadataService.getRelatedApplicationTypeMetadata(entity,entityDetails,mid);
  if (entityPersistentDetails == null || relatedEntities == null || relatedEntities.get(entity) == null || relatedEntities.get(entity).getPersistenceDetails() == null) {
    return null;
  }
  JavaType oldEntity=webScaffoldMidToEntityMap.get(mid);
  if (oldEntity != null) {
    entityToWebScaffoldMidMap.remove(oldEntity);
  }
  entityToWebScaffoldMidMap.put(entity,mid);
  webScaffoldMidToEntityMap.put(mid,entity);
  MemberDetails controllerDetails=getMemberDetails(controllerMetadata);
  Map<JavaSymbolName,DateTimeFormatDetails> entityDateTypes=webMetadataService.getDatePatterns(entity,entityDetails,mid);
  OperationUtils.installWebDialogClass(aspect.getPackage().getFullyQualifiedPackageName().concat("String_Node_Str"),projectOperations.getPathResolver(),fileManager);
  SortedMap<JavaType,JavaTypeMetadataDetails> relatedFields=getRelationFieldsDetails(mid,controllerMetadata,entity,webMetadataService);
  Map<JavaType,Map<JavaSymbolName,DateTimeFormatDetails>> relatedDates=getRelationFieldsDateFormat(mid,controllerMetadata,entity,webMetadataService);
  return new PatternMetadata(mid,aspect,controllerMetadata,controllerDetails,webScaffoldMetadata,patternList,entityMetadata,relatedEntities,relatedFields,relatedDates,entityDateTypes);
}