Program: 60289
Project: 60289
Buggy source:
private Map decodeMap(){
  ParameterizedType paramType=(ParameterizedType)field.getGenericType();
  Type[] types=paramType.getActualTypeArguments();
  boolean isArray=false;
  boolean isCollection=false;
  boolean isSingle=false;
  Class vType=null;
  Class elementType=null;
  if (types[1] instanceof GenericArrayType) {
    isArray=true;
    GenericArrayType g=(GenericArrayType)types[1];
    elementType=(Class)g.getGenericComponentType();
  }
 else   if (types[1] instanceof ParameterizedType) {
    isCollection=true;
    ParameterizedType p=(ParameterizedType)types[1];
    vType=(Class)p.getRawType();
    elementType=(Class)p.getActualTypeArguments()[0];
  }
 else {
    Class<?> actualType=FieldUtil.getClassOfType(types[1]);
    if (actualType.isArray()) {
      isArray=true;
      elementType=actualType.getComponentType();
    }
 else {
      isSingle=true;
    }
  }
  Map map=(Map)value;
  Map result=new HashMap();
  boolean cascadeRead=false;
  Class<?> cls=null;
  InternalDao dao=null;
  if (isSingle) {
    cls=FieldUtil.getRealType((Class)types[1],field);
    cascadeRead=(refList.cascade().toUpperCase().indexOf(Default.CASCADE_READ) != -1);
    if (cascadeRead) {
      dao=DaoCache.getInstance().get(cls);
    }
  }
  for (  Object key : map.keySet()) {
    Object entryValue=map.get(key);
    if (entryValue == null) {
      result.put(key,null);
      continue;
    }
    if (isSingle) {
      String refId=ReferenceUtil.fromDbReference(refList,entryValue);
      BuguEntity refObj=null;
      if (cascadeRead) {
        refObj=(BuguEntity)dao.findOneLazily(refId);
      }
 else {
        refObj=(BuguEntity)ConstructorCache.getInstance().create(cls);
        refObj.setId(refId);
      }
      result.put(key,refObj);
    }
 else     if (isArray) {
      Object arr=decodeArray(entryValue,elementType);
      result.put(key,arr);
    }
 else     if (isCollection) {
      List list=decodeCollection(entryValue,elementType);
      if (DataType.isListType(vType) || DataType.isCollectionType(vType)) {
        result.put(key,list);
      }
 else       if (DataType.isSetType(vType)) {
        result.put(key,new HashSet(list));
      }
 else       if (DataType.isQueueType(vType)) {
        result.put(key,new LinkedList(list));
      }
    }
  }
  return result;
}

Fixed version (ground truth):
private Map decodeMap(){
  ParameterizedType paramType=(ParameterizedType)field.getGenericType();
  Type[] types=paramType.getActualTypeArguments();
  boolean isArray=false;
  boolean isCollection=false;
  boolean isSingle=false;
  Class vType=null;
  Class elementType=null;
  if (types[1] instanceof GenericArrayType) {
    isArray=true;
    GenericArrayType g=(GenericArrayType)types[1];
    elementType=(Class)g.getGenericComponentType();
  }
 else   if (types[1] instanceof ParameterizedType) {
    isCollection=true;
    ParameterizedType p=(ParameterizedType)types[1];
    vType=(Class)p.getRawType();
    elementType=(Class)p.getActualTypeArguments()[0];
  }
 else {
    Class<?> actualType=FieldUtil.getClassOfType(types[1]);
    if (actualType.isArray()) {
      isArray=true;
      elementType=actualType.getComponentType();
    }
 else {
      isSingle=true;
    }
  }
  Map map=(Map)value;
  Map result=new HashMap();
  boolean cascadeRead=false;
  Class<?> cls=null;
  InternalDao dao=null;
  if (isSingle) {
    cls=FieldUtil.getRealType((Class)types[1],field);
    cascadeRead=(refList.cascade().toUpperCase().indexOf(Default.CASCADE_READ) != -1);
    if (!withoutCascade && cascadeRead) {
      dao=DaoCache.getInstance().get(cls);
    }
  }
  for (  Object key : map.keySet()) {
    Object entryValue=map.get(key);
    if (entryValue == null) {
      result.put(key,null);
      continue;
    }
    if (isSingle) {
      String refId=ReferenceUtil.fromDbReference(refList,entryValue);
      BuguEntity refObj=null;
      if (!withoutCascade && cascadeRead) {
        refObj=(BuguEntity)dao.findOneLazily(refId,true);
      }
 else {
        refObj=(BuguEntity)ConstructorCache.getInstance().create(cls);
        refObj.setId(refId);
      }
      result.put(key,refObj);
    }
 else     if (isArray) {
      Object arr=decodeArray(entryValue,elementType);
      result.put(key,arr);
    }
 else     if (isCollection) {
      List list=decodeCollection(entryValue,elementType);
      if (DataType.isListType(vType) || DataType.isCollectionType(vType)) {
        result.put(key,list);
      }
 else       if (DataType.isSetType(vType)) {
        result.put(key,new HashSet(list));
      }
 else       if (DataType.isQueueType(vType)) {
        result.put(key,new LinkedList(list));
      }
    }
  }
  return result;
}