Program: 177927
Project: 177927
Buggy source:
/** 
 * Fills given class filled with values dictated by the strategy
 * @param < T > The type for which should be populated
 * @param pojo An instance to be filled with dummy values
 * @param manufacturingCtx the manufacturing context
 * @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 An instance of &lt;T&gt; filled with dummy values
 * @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 ClassNotFoundException If manufactured class cannot be loaded
 */
private <T>T populatePojoInternal(T pojo,ManufacturingContext manufacturingCtx,Map<String,Type> typeArgsMap,Type... genericTypeArgs) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
  Class<?> pojoClass=pojo.getClass();
  if (pojo instanceof Collection && ((Collection<?>)pojo).isEmpty()) {
    @SuppressWarnings("String_Node_Str") Collection<Object> collection=(Collection<Object>)pojo;
    AtomicReference<Type[]> elementGenericTypeArgs=new AtomicReference<Type[]>(PodamConstants.NO_TYPES);
    Class<?> elementTypeClass=findInheretedCollectionElementType(collection,manufacturingCtx,elementGenericTypeArgs,typeArgsMap,genericTypeArgs);
    String attributeName=null;
    Annotation[] annotations=collection.getClass().getAnnotations();
    fillCollection(manufacturingCtx,Arrays.asList(annotations),attributeName,collection,elementTypeClass,elementGenericTypeArgs.get());
  }
 else   if (pojo instanceof Map && ((Map<?,?>)pojo).isEmpty()) {
    @SuppressWarnings("String_Node_Str") Map<Object,Object> map=(Map<Object,Object>)pojo;
    MapArguments mapArguments=findInheretedMapElementType(map,manufacturingCtx,typeArgsMap,genericTypeArgs);
    fillMap(mapArguments,manufacturingCtx);
  }
  Class<?>[] parameterTypes=null;
  Class<?> attributeType=null;
  ClassInfo classInfo=classInfoStrategy.getClassInfo(pojo.getClass());
  Set<ClassAttribute> classAttributes=classInfo.getClassAttributes();
  Object setterArg=null;
  Iterator<ClassAttribute> iter=classAttributes.iterator();
  while (iter.hasNext()) {
    ClassAttribute attribute=iter.next();
    Set<Method> setters=attribute.getSetters();
    if (setters.isEmpty()) {
      if (attribute.getGetters().isEmpty()) {
        iter.remove();
      }
      continue;
    }
 else {
      iter.remove();
    }
    Method setter=null;
    for (    Method current : setters) {
      if (setter == null || setter.getDeclaringClass().isAssignableFrom(current.getDeclaringClass())) {
        setter=current;
      }
    }
    parameterTypes=setter.getParameterTypes();
    if (parameterTypes.length != 1) {
      LOG.warn("String_Node_Str",setter);
      continue;
    }
    attributeType=parameterTypes[0];
    String attributeName=PodamUtils.extractFieldNameFromSetterMethod(setter);
    List<Annotation> pojoAttributeAnnotations=PodamUtils.getAttributeAnnotations(attribute.getAttribute(),setter);
    AttributeStrategy<?> attributeStrategy=TypeManufacturerUtil.findAttributeStrategy(strategy,pojoAttributeAnnotations,attributeType);
    if (null != attributeStrategy) {
      LOG.debug("String_Node_Str" + attributeName + "String_Node_Str"+ attributeStrategy);
      setterArg=TypeManufacturerUtil.returnAttributeDataStrategyValue(attributeType,attributeStrategy);
    }
 else {
      Type[] typeArguments=PodamConstants.NO_TYPES;
      Type genericType=setter.getGenericParameterTypes()[0];
      if (genericType instanceof ParameterizedType) {
        final ParameterizedType attributeParameterizedType=(ParameterizedType)genericType;
        typeArguments=attributeParameterizedType.getActualTypeArguments();
      }
 else       if (genericType instanceof TypeVariable) {
        final TypeVariable<?> typeVariable=(TypeVariable<?>)genericType;
        Type type=typeArgsMap.get(typeVariable.getName());
        if (type instanceof ParameterizedType) {
          final ParameterizedType attributeParameterizedType=(ParameterizedType)type;
          typeArguments=attributeParameterizedType.getActualTypeArguments();
          attributeType=(Class<?>)attributeParameterizedType.getRawType();
        }
 else {
          attributeType=(Class<?>)type;
        }
      }
      AtomicReference<Type[]> typeGenericTypeArgs=new AtomicReference<Type[]>(PodamConstants.NO_TYPES);
      for (int i=0; i < typeArguments.length; i++) {
        if (typeArguments[i] instanceof TypeVariable) {
          Class<?> resolvedType=TypeManufacturerUtil.resolveGenericParameter(typeArguments[i],typeArgsMap,typeGenericTypeArgs);
          if (!Collection.class.isAssignableFrom(resolvedType) && !Map.class.isAssignableFrom(resolvedType)) {
            typeArguments[i]=resolvedType;
          }
        }
      }
      setterArg=manufactureAttributeValue(pojo,manufacturingCtx,attributeType,genericType,pojoAttributeAnnotations,attributeName,typeArgsMap,typeArguments);
    }
    try {
      setter.invoke(pojo,setterArg);
    }
 catch (    IllegalAccessException e) {
      LOG.warn("String_Node_Str" + "String_Node_Str" + "String_Node_Str",setter.toString());
      setter.setAccessible(true);
      setter.invoke(pojo,setterArg);
    }
  }
  for (  ClassAttribute readOnlyAttribute : classAttributes) {
    Method getter=readOnlyAttribute.getGetters().iterator().next();
    if (getter != null && !getter.getReturnType().isPrimitive()) {
      if (getter.getGenericParameterTypes().length == 0) {
        Object fieldValue=null;
        try {
          fieldValue=getter.invoke(pojo,PodamConstants.NO_ARGS);
        }
 catch (        Exception e) {
          LOG.debug("String_Node_Str",getter);
        }
        if (fieldValue != null) {
          LOG.debug("String_Node_Str",getter);
          Type[] genericTypeArgsAll;
          Map<String,Type> paramTypeArgsMap;
          if (getter.getGenericReturnType() instanceof ParameterizedType) {
            paramTypeArgsMap=new HashMap<String,Type>(typeArgsMap);
            ParameterizedType paramType=(ParameterizedType)getter.getGenericReturnType();
            Type[] actualTypes=paramType.getActualTypeArguments();
            TypeManufacturerUtil.fillTypeArgMap(paramTypeArgsMap,getter.getReturnType(),actualTypes);
            genericTypeArgsAll=TypeManufacturerUtil.fillTypeArgMap(paramTypeArgsMap,getter.getReturnType(),genericTypeArgs);
          }
 else {
            paramTypeArgsMap=typeArgsMap;
            genericTypeArgsAll=genericTypeArgs;
          }
          Class<?> fieldClass=fieldValue.getClass();
          Integer depth=manufacturingCtx.getPojos().get(fieldClass);
          if (depth == null) {
            depth=-1;
          }
          if (depth <= strategy.getMaxDepth(fieldClass)) {
            manufacturingCtx.getPojos().put(fieldClass,depth + 1);
            populatePojoInternal(fieldValue,manufacturingCtx,paramTypeArgsMap,genericTypeArgsAll);
            manufacturingCtx.getPojos().put(fieldClass,depth);
          }
 else {
            LOG.warn("String_Node_Str",getter);
          }
        }
      }
 else {
        LOG.warn("String_Node_Str",getter);
      }
    }
  }
  Collection<Method> extraMethods=classInfoStrategy.getExtraMethods(pojoClass);
  if (null != extraMethods) {
    for (    Method extraMethod : extraMethods) {
      Object[] args=getParameterValuesForMethod(extraMethod,pojoClass,manufacturingCtx,typeArgsMap,genericTypeArgs);
      extraMethod.invoke(pojo,args);
    }
  }
  return pojo;
}

Fixed version (ground truth):
/** 
 * Fills given class filled with values dictated by the strategy
 * @param < T > The type for which should be populated
 * @param pojo An instance to be filled with dummy values
 * @param manufacturingCtx the manufacturing context
 * @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 An instance of &lt;T&gt; filled with dummy values
 * @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 ClassNotFoundException If manufactured class cannot be loaded
 */
private <T>T populatePojoInternal(T pojo,ManufacturingContext manufacturingCtx,Map<String,Type> typeArgsMap,Type... genericTypeArgs) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
  Class<?> pojoClass=pojo.getClass();
  if (pojo instanceof Collection && ((Collection<?>)pojo).isEmpty()) {
    @SuppressWarnings("String_Node_Str") Collection<Object> collection=(Collection<Object>)pojo;
    AtomicReference<Type[]> elementGenericTypeArgs=new AtomicReference<Type[]>(PodamConstants.NO_TYPES);
    Class<?> elementTypeClass=findInheretedCollectionElementType(collection,manufacturingCtx,elementGenericTypeArgs,typeArgsMap,genericTypeArgs);
    String attributeName=null;
    Annotation[] annotations=collection.getClass().getAnnotations();
    fillCollection(manufacturingCtx,Arrays.asList(annotations),attributeName,collection,elementTypeClass,elementGenericTypeArgs.get());
  }
 else   if (pojo instanceof Map && ((Map<?,?>)pojo).isEmpty()) {
    @SuppressWarnings("String_Node_Str") Map<Object,Object> map=(Map<Object,Object>)pojo;
    MapArguments mapArguments=findInheretedMapElementType(map,manufacturingCtx,typeArgsMap,genericTypeArgs);
    fillMap(mapArguments,manufacturingCtx);
  }
  Class<?>[] parameterTypes=null;
  Class<?> attributeType=null;
  ClassInfo classInfo=classInfoStrategy.getClassInfo(pojo.getClass());
  Set<ClassAttribute> classAttributes=classInfo.getClassAttributes();
  Object setterArg=null;
  Iterator<ClassAttribute> iter=classAttributes.iterator();
  while (iter.hasNext()) {
    ClassAttribute attribute=iter.next();
    Set<Method> setters=attribute.getSetters();
    if (setters.isEmpty()) {
      if (attribute.getGetters().isEmpty()) {
        iter.remove();
      }
      continue;
    }
 else {
      iter.remove();
    }
    Method setter=null;
    for (    Method current : setters) {
      if (setter == null || setter.getDeclaringClass().isAssignableFrom(current.getDeclaringClass())) {
        setter=current;
      }
    }
    parameterTypes=setter.getParameterTypes();
    if (parameterTypes.length != 1) {
      LOG.warn("String_Node_Str",setter);
      continue;
    }
    attributeType=parameterTypes[0];
    String attributeName=PodamUtils.extractFieldNameFromSetterMethod(setter);
    List<Annotation> pojoAttributeAnnotations=PodamUtils.getAttributeAnnotations(attribute.getAttribute(),setter);
    AttributeStrategy<?> attributeStrategy=TypeManufacturerUtil.findAttributeStrategy(strategy,pojoAttributeAnnotations,attributeType);
    if (null != attributeStrategy) {
      LOG.debug("String_Node_Str" + attributeName + "String_Node_Str"+ attributeStrategy);
      setterArg=TypeManufacturerUtil.returnAttributeDataStrategyValue(attributeType,attributeStrategy);
    }
 else {
      AtomicReference<Type[]> typeGenericTypeArgs=new AtomicReference<Type[]>(PodamConstants.NO_TYPES);
      Type genericType=setter.getGenericParameterTypes()[0];
      final Type[] typeArguments;
      if (!(genericType instanceof GenericArrayType)) {
        attributeType=TypeManufacturerUtil.resolveGenericParameter(genericType,typeArgsMap,typeGenericTypeArgs);
        typeArguments=typeGenericTypeArgs.get();
      }
 else {
        typeArguments=PodamConstants.NO_TYPES;
      }
      for (int i=0; i < typeArguments.length; i++) {
        if (typeArguments[i] instanceof TypeVariable) {
          Class<?> resolvedType=TypeManufacturerUtil.resolveGenericParameter(typeArguments[i],typeArgsMap,typeGenericTypeArgs);
          if (!Collection.class.isAssignableFrom(resolvedType) && !Map.class.isAssignableFrom(resolvedType)) {
            typeArguments[i]=resolvedType;
          }
        }
      }
      setterArg=manufactureAttributeValue(pojo,manufacturingCtx,attributeType,genericType,pojoAttributeAnnotations,attributeName,typeArgsMap,typeArguments);
    }
    try {
      setter.invoke(pojo,setterArg);
    }
 catch (    IllegalAccessException e) {
      LOG.warn("String_Node_Str" + "String_Node_Str" + "String_Node_Str",setter.toString());
      setter.setAccessible(true);
      setter.invoke(pojo,setterArg);
    }
  }
  for (  ClassAttribute readOnlyAttribute : classAttributes) {
    Method getter=readOnlyAttribute.getGetters().iterator().next();
    if (getter != null && !getter.getReturnType().isPrimitive()) {
      if (getter.getGenericParameterTypes().length == 0) {
        Object fieldValue=null;
        try {
          fieldValue=getter.invoke(pojo,PodamConstants.NO_ARGS);
        }
 catch (        Exception e) {
          LOG.debug("String_Node_Str",getter);
        }
        if (fieldValue != null) {
          LOG.debug("String_Node_Str",getter);
          Type[] genericTypeArgsAll;
          Map<String,Type> paramTypeArgsMap;
          if (getter.getGenericReturnType() instanceof ParameterizedType) {
            paramTypeArgsMap=new HashMap<String,Type>(typeArgsMap);
            ParameterizedType paramType=(ParameterizedType)getter.getGenericReturnType();
            Type[] actualTypes=paramType.getActualTypeArguments();
            TypeManufacturerUtil.fillTypeArgMap(paramTypeArgsMap,getter.getReturnType(),actualTypes);
            genericTypeArgsAll=TypeManufacturerUtil.fillTypeArgMap(paramTypeArgsMap,getter.getReturnType(),genericTypeArgs);
          }
 else {
            paramTypeArgsMap=typeArgsMap;
            genericTypeArgsAll=genericTypeArgs;
          }
          Class<?> fieldClass=fieldValue.getClass();
          Integer depth=manufacturingCtx.getPojos().get(fieldClass);
          if (depth == null) {
            depth=-1;
          }
          if (depth <= strategy.getMaxDepth(fieldClass)) {
            manufacturingCtx.getPojos().put(fieldClass,depth + 1);
            populatePojoInternal(fieldValue,manufacturingCtx,paramTypeArgsMap,genericTypeArgsAll);
            manufacturingCtx.getPojos().put(fieldClass,depth);
          }
 else {
            LOG.warn("String_Node_Str",getter);
          }
        }
      }
 else {
        LOG.warn("String_Node_Str",getter);
      }
    }
  }
  Collection<Method> extraMethods=classInfoStrategy.getExtraMethods(pojoClass);
  if (null != extraMethods) {
    for (    Method extraMethod : extraMethods) {
      Object[] args=getParameterValuesForMethod(extraMethod,pojoClass,manufacturingCtx,typeArgsMap,genericTypeArgs);
      extraMethod.invoke(pojo,args);
    }
  }
  return pojo;
}