Program: 85149
Project: 85149
Buggy source:
private static void serializeInternal(JavaBeanDescriptor descriptor,Object obj,JavaBeanAccessor accessor,IdentityHashMap<Object,JavaBeanDescriptor> cache){
  if (obj == null || descriptor == null) {
    return;
  }
  if (obj.getClass().isEnum()) {
    descriptor.setEnumNameProperty(((Enum<?>)obj).name());
  }
 else   if (ReflectUtils.isPrimitive(obj.getClass())) {
    descriptor.setPrimitiveProperty(obj);
  }
 else   if (Class.class.equals(obj.getClass())) {
    descriptor.setClassNameProperty(((Class<?>)obj).getName());
  }
 else   if (obj.getClass().isArray()) {
    int len=Array.getLength(obj);
    for (int i=0; i < len; i++) {
      Object item=Array.get(obj,i);
      if (item == null) {
        descriptor.setProperty(i++,null);
      }
 else {
        JavaBeanDescriptor itemDescriptor=createDescriptorIfAbsent(item,accessor,cache);
        descriptor.setProperty(i,itemDescriptor);
      }
    }
  }
 else   if (obj instanceof Collection) {
    Collection collection=(Collection)obj;
    int index=0;
    for (    Object item : collection) {
      if (item == null) {
        descriptor.setProperty(index++,null);
      }
 else {
        JavaBeanDescriptor itemDescriptor=createDescriptorIfAbsent(item,accessor,cache);
        descriptor.setProperty(index++,itemDescriptor);
      }
    }
  }
 else   if (obj instanceof Map) {
    Map map=(Map)obj;
    for (    Object key : map.keySet()) {
      Object value=map.get(key);
      Object keyDescriptor=key == null ? null : createDescriptorIfAbsent(key,accessor,cache);
      Object valueDescriptor=value == null ? null : createDescriptorIfAbsent(value,accessor,cache);
      descriptor.setProperty(keyDescriptor,valueDescriptor);
    }
  }
 else {
    if (JavaBeanAccessor.isAccessByMethod(accessor)) {
      Map<String,Method> methods=ReflectUtils.getBeanPropertyReadMethods(obj.getClass());
      for (      Map.Entry<String,Method> entry : methods.entrySet()) {
        try {
          Object value=entry.getValue().invoke(obj);
          if (value == null) {
            continue;
          }
          JavaBeanDescriptor valueDescriptor=createDescriptorIfAbsent(value,accessor,cache);
          descriptor.setProperty(entry.getKey(),valueDescriptor);
        }
 catch (        Exception e) {
          throw new RuntimeException(e.getMessage(),e);
        }
      }
    }
    if (JavaBeanAccessor.isAccessByField(accessor)) {
      Map<String,Field> fields=ReflectUtils.getBeanPropertyFields(obj.getClass());
      for (      Map.Entry<String,Field> entry : fields.entrySet()) {
        if (!descriptor.containsProperty(entry.getKey())) {
          try {
            Object value=entry.getValue().get(obj);
            if (value == null) {
              continue;
            }
            JavaBeanDescriptor valueDescriptor=createDescriptorIfAbsent(value,accessor,cache);
            descriptor.setProperty(entry.getKey(),valueDescriptor);
          }
 catch (          Exception e) {
            throw new RuntimeException(e.getMessage(),e);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private static void serializeInternal(JavaBeanDescriptor descriptor,Object obj,JavaBeanAccessor accessor,IdentityHashMap<Object,JavaBeanDescriptor> cache){
  if (obj == null || descriptor == null) {
    return;
  }
  if (obj.getClass().isEnum()) {
    descriptor.setEnumNameProperty(((Enum<?>)obj).name());
  }
 else   if (ReflectUtils.isPrimitive(obj.getClass())) {
    descriptor.setPrimitiveProperty(obj);
  }
 else   if (Class.class.equals(obj.getClass())) {
    descriptor.setClassNameProperty(((Class<?>)obj).getName());
  }
 else   if (obj.getClass().isArray()) {
    int len=Array.getLength(obj);
    for (int i=0; i < len; i++) {
      Object item=Array.get(obj,i);
      if (item == null) {
        descriptor.setProperty(i,null);
      }
 else {
        JavaBeanDescriptor itemDescriptor=createDescriptorIfAbsent(item,accessor,cache);
        descriptor.setProperty(i,itemDescriptor);
      }
    }
  }
 else   if (obj instanceof Collection) {
    Collection collection=(Collection)obj;
    int index=0;
    for (    Object item : collection) {
      if (item == null) {
        descriptor.setProperty(index++,null);
      }
 else {
        JavaBeanDescriptor itemDescriptor=createDescriptorIfAbsent(item,accessor,cache);
        descriptor.setProperty(index++,itemDescriptor);
      }
    }
  }
 else   if (obj instanceof Map) {
    Map map=(Map)obj;
    for (    Object key : map.keySet()) {
      Object value=map.get(key);
      Object keyDescriptor=key == null ? null : createDescriptorIfAbsent(key,accessor,cache);
      Object valueDescriptor=value == null ? null : createDescriptorIfAbsent(value,accessor,cache);
      descriptor.setProperty(keyDescriptor,valueDescriptor);
    }
  }
 else {
    if (JavaBeanAccessor.isAccessByMethod(accessor)) {
      Map<String,Method> methods=ReflectUtils.getBeanPropertyReadMethods(obj.getClass());
      for (      Map.Entry<String,Method> entry : methods.entrySet()) {
        try {
          Object value=entry.getValue().invoke(obj);
          if (value == null) {
            continue;
          }
          JavaBeanDescriptor valueDescriptor=createDescriptorIfAbsent(value,accessor,cache);
          descriptor.setProperty(entry.getKey(),valueDescriptor);
        }
 catch (        Exception e) {
          throw new RuntimeException(e.getMessage(),e);
        }
      }
    }
    if (JavaBeanAccessor.isAccessByField(accessor)) {
      Map<String,Field> fields=ReflectUtils.getBeanPropertyFields(obj.getClass());
      for (      Map.Entry<String,Field> entry : fields.entrySet()) {
        if (!descriptor.containsProperty(entry.getKey())) {
          try {
            Object value=entry.getValue().get(obj);
            if (value == null) {
              continue;
            }
            JavaBeanDescriptor valueDescriptor=createDescriptorIfAbsent(value,accessor,cache);
            descriptor.setProperty(entry.getKey(),valueDescriptor);
          }
 catch (          Exception e) {
            throw new RuntimeException(e.getMessage(),e);
          }
        }
      }
    }
  }
}