Program: 175904
Project: 175904
Buggy source:
/** 
 * It manufactures and returns the value for a POJO attribute.
 * @param pojo The POJO being filled with values
 * @param manufacturingCtx the manufacturing context
 * @param attributeType The type of the attribute for which a value is being manufactured
 * @param genericAttributeType The generic type of the attribute for which a value is being manufactured
 * @param annotations The annotations for the attribute being considered
 * @param attributeName The attribute name
 * @param typeArgsMap a map relating the generic class arguments ("&lt;T, V&gt;" for example) with their actual types
 * @param genericTypeArgs The generic type arguments for the current generic class instance
 * @return The value for an attribute
 * @throws InstantiationException If an exception occurred during instantiation
 * @throws IllegalAccessException If security was violated while creating the object
 * @throws InvocationTargetException If an exception occurred while invoking the constructor or factory method
 * @throws IllegalArgumentException <ul> <li>If an illegal argument was passed</li> <li>If an invalid value was set for a precise value in an annotation and such value could not be converted to the desired type</li> </ul>
 * @throws ClassNotFoundException If class being manufactured cannot be loaded
 */
private Object manufactureAttributeValue(Object pojo,ManufacturingContext manufacturingCtx,Class<?> attributeType,Type genericAttributeType,List<Annotation> annotations,String attributeName,Map<String,Type> typeArgsMap,Type... genericTypeArgs) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
  Object attributeValue=null;
  Class<?> pojoClass=(pojo instanceof Class ? (Class<?>)pojo : pojo.getClass());
  Class<?> realAttributeType;
  if (attributeType != genericAttributeType && Object.class.equals(attributeType) && genericAttributeType instanceof TypeVariable) {
    AtomicReference<Type[]> elementGenericTypeArgs=new AtomicReference<Type[]>(PodamConstants.NO_TYPES);
    realAttributeType=TypeManufacturerUtil.resolveGenericParameter(genericAttributeType,typeArgsMap,elementGenericTypeArgs);
  }
 else {
    realAttributeType=attributeType;
  }
  Type[] genericTypeArgsAll=TypeManufacturerUtil.mergeActualAndSuppliedGenericTypes(attributeType,genericAttributeType,genericTypeArgs,typeArgsMap);
  AttributeMetadata attributeMetadata=new AttributeMetadata(attributeName,realAttributeType,genericAttributeType,genericTypeArgsAll,annotations,pojoClass,pojo);
  if (realAttributeType.isArray()) {
    attributeValue=resolveArrayElementValue(pojo,manufacturingCtx,attributeMetadata,typeArgsMap);
  }
 else   if (Collection.class.isAssignableFrom(realAttributeType)) {
    attributeValue=resolveCollectionValueWhenCollectionIsPojoAttribute(pojo,manufacturingCtx,attributeMetadata,typeArgsMap);
  }
 else   if (Map.class.isAssignableFrom(realAttributeType)) {
    attributeValue=resolveMapValueWhenMapIsPojoAttribute(pojo,manufacturingCtx,attributeMetadata,typeArgsMap);
  }
  if (attributeValue == null) {
    Integer depth=manufacturingCtx.getPojos().get(realAttributeType);
    if (depth == null) {
      depth=-1;
    }
    if (depth <= strategy.getMaxDepth(pojoClass)) {
      manufacturingCtx.getPojos().put(realAttributeType,depth + 1);
      attributeValue=this.manufacturePojoInternal(realAttributeType,attributeMetadata,manufacturingCtx,genericTypeArgsAll);
      manufacturingCtx.getPojos().put(realAttributeType,depth);
    }
 else {
      attributeValue=resortToExternalFactory(manufacturingCtx,"String_Node_Str" + depth + "String_Node_Str",realAttributeType,genericTypeArgsAll);
    }
  }
  return attributeValue;
}

Fixed version (ground truth):
/** 
 * It manufactures and returns the value for a POJO attribute.
 * @param pojo The POJO being filled with values
 * @param manufacturingCtx the manufacturing context
 * @param attributeType The type of the attribute for which a value is being manufactured
 * @param genericAttributeType The generic type of the attribute for which a value is being manufactured
 * @param annotations The annotations for the attribute being considered
 * @param attributeName The attribute name
 * @param typeArgsMap a map relating the generic class arguments ("&lt;T, V&gt;" for example) with their actual types
 * @param genericTypeArgs The generic type arguments for the current generic class instance
 * @return The value for an attribute
 * @throws InstantiationException If an exception occurred during instantiation
 * @throws IllegalAccessException If security was violated while creating the object
 * @throws InvocationTargetException If an exception occurred while invoking the constructor or factory method
 * @throws IllegalArgumentException <ul> <li>If an illegal argument was passed</li> <li>If an invalid value was set for a precise value in an annotation and such value could not be converted to the desired type</li> </ul>
 * @throws ClassNotFoundException If class being manufactured cannot be loaded
 */
private Object manufactureAttributeValue(Object pojo,ManufacturingContext manufacturingCtx,Class<?> attributeType,Type genericAttributeType,List<Annotation> annotations,String attributeName,Map<String,Type> typeArgsMap,Type... genericTypeArgs) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
  Object attributeValue=null;
  Class<?> pojoClass=(pojo instanceof Class ? (Class<?>)pojo : pojo.getClass());
  Class<?> realAttributeType;
  if (attributeType != genericAttributeType && Object.class.equals(attributeType) && genericAttributeType instanceof TypeVariable) {
    AtomicReference<Type[]> elementGenericTypeArgs=new AtomicReference<Type[]>(PodamConstants.NO_TYPES);
    realAttributeType=TypeManufacturerUtil.resolveGenericParameter(genericAttributeType,typeArgsMap,elementGenericTypeArgs);
  }
 else {
    realAttributeType=attributeType;
  }
  Type[] genericTypeArgsAll=TypeManufacturerUtil.mergeActualAndSuppliedGenericTypes(attributeType,genericAttributeType,genericTypeArgs,typeArgsMap);
  AttributeMetadata attributeMetadata=new AttributeMetadata(attributeName,realAttributeType,genericAttributeType,genericTypeArgsAll,annotations,pojoClass,pojo);
  if (realAttributeType.isArray()) {
    attributeValue=resolveArrayElementValue(pojo,manufacturingCtx,attributeMetadata,typeArgsMap);
  }
 else   if (Collection.class.isAssignableFrom(realAttributeType)) {
    attributeValue=resolveCollectionValueWhenCollectionIsPojoAttribute(pojo,manufacturingCtx,attributeMetadata,typeArgsMap);
  }
 else   if (Map.class.isAssignableFrom(realAttributeType)) {
    attributeValue=resolveMapValueWhenMapIsPojoAttribute(pojo,manufacturingCtx,attributeMetadata,typeArgsMap);
  }
  if (attributeValue == null) {
    Integer depth=manufacturingCtx.getPojos().get(realAttributeType);
    if (depth == null) {
      depth=0;
    }
    if (depth < strategy.getMaxDepth(pojoClass)) {
      manufacturingCtx.getPojos().put(realAttributeType,depth + 1);
      attributeValue=this.manufacturePojoInternal(realAttributeType,attributeMetadata,manufacturingCtx,genericTypeArgsAll);
      manufacturingCtx.getPojos().put(realAttributeType,depth);
    }
 else {
      attributeValue=resortToExternalFactory(manufacturingCtx,"String_Node_Str" + depth + "String_Node_Str",realAttributeType,genericTypeArgsAll);
    }
  }
  return attributeValue;
}