Program: 175922
Project: 175922
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;
  }
  TypeVariable<?>[] typeParams=attributeType.getTypeParameters();
  Type[] genericTypeArgsAll;
  if (typeParams.length > genericTypeArgs.length) {
    genericTypeArgsAll=TypeManufacturerUtil.mergeActualAndSuppliedGenericTypes(typeParams,genericAttributeType,genericTypeArgs,typeArgsMap);
  }
 else {
    genericTypeArgsAll=genericTypeArgs;
  }
  AttributeMetadata attributeMetadata=new AttributeMetadata(attributeName,realAttributeType,genericAttributeType,genericTypeArgsAll,annotations,pojoClass);
  if (realAttributeType.isPrimitive() || TypeManufacturerUtil.isWrapper(realAttributeType) || realAttributeType.equals(String.class)) {
    attributeValue=typeMultiplexer.getTypeValue(strategy,attributeMetadata,typeArgsMap,realAttributeType.getName());
  }
 else   if (realAttributeType.isArray()) {
    attributeValue=resolveArrayElementValue(realAttributeType,genericAttributeType,attributeName,manufacturingCtx,annotations,pojo,typeArgsMap);
  }
 else   if (Collection.class.isAssignableFrom(realAttributeType)) {
    attributeValue=resolveCollectionValueWhenCollectionIsPojoAttribute(pojo,manufacturingCtx,realAttributeType,attributeName,annotations,typeArgsMap,genericTypeArgsAll);
  }
 else   if (Map.class.isAssignableFrom(realAttributeType)) {
    attributeValue=resolveMapValueWhenMapIsPojoAttribute(pojo,manufacturingCtx,realAttributeType,attributeName,annotations,typeArgsMap,genericTypeArgsAll);
  }
 else   if (realAttributeType.isEnum()) {
    attributeValue=typeMultiplexer.getTypeValue(strategy,attributeMetadata,typeArgsMap,PodamConstants.ENUMERATION_QUALIFIER);
  }
 else   if (Type.class.isAssignableFrom(realAttributeType)) {
    attributeValue=typeMultiplexer.getTypeValue(strategy,attributeMetadata,typeArgsMap,PodamConstants.GENERIC_TYPE_QUALIFIER);
  }
  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",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;
  }
  TypeVariable<?>[] typeParams=attributeType.getTypeParameters();
  Type[] genericTypeArgsAll;
  if (typeParams.length > genericTypeArgs.length) {
    genericTypeArgsAll=TypeManufacturerUtil.mergeActualAndSuppliedGenericTypes(typeParams,genericAttributeType,genericTypeArgs,typeArgsMap);
  }
 else {
    genericTypeArgsAll=genericTypeArgs;
  }
  AttributeMetadata attributeMetadata=new AttributeMetadata(attributeName,realAttributeType,genericAttributeType,genericTypeArgsAll,annotations,pojoClass);
  if (realAttributeType.isArray()) {
    attributeValue=resolveArrayElementValue(realAttributeType,genericAttributeType,attributeName,manufacturingCtx,annotations,pojo,typeArgsMap);
  }
 else   if (Collection.class.isAssignableFrom(realAttributeType)) {
    attributeValue=resolveCollectionValueWhenCollectionIsPojoAttribute(pojo,manufacturingCtx,realAttributeType,attributeName,annotations,typeArgsMap,genericTypeArgsAll);
  }
 else   if (Map.class.isAssignableFrom(realAttributeType)) {
    attributeValue=resolveMapValueWhenMapIsPojoAttribute(pojo,manufacturingCtx,realAttributeType,attributeName,annotations,typeArgsMap,genericTypeArgsAll);
  }
 else   if (Type.class.isAssignableFrom(realAttributeType)) {
    attributeValue=typeMultiplexer.getTypeValue(strategy,attributeMetadata,typeArgsMap,PodamConstants.GENERIC_TYPE_QUALIFIER);
  }
  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",realAttributeType,genericTypeArgsAll);
    }
  }
  return attributeValue;
}