Program: 53620
Project: 53620
Buggy source:
/** 
 * Returns a map of properties that differ (via   {@link Object#equals(Object)}) between two AutoBeans. The keys are property names and the values are the value of the property in <code>b</code>. Properties present in <code>a</code> but missing in <code>b</code> will be represented by <code>null</code> values. This implementation will compare AutoBeans of different parameterizations, although the diff produced is likely meaningless. <p> This will work for both simple and wrapper AutoBeans.
 * @param a an {@link AutoBean}
 * @param b an {@link AutoBean}
 * @return a {@link Map} of differing properties
 */
public static Map<String,Object> diff(AutoBean<?> a,AutoBean<?> b){
  if (a.equals(b)) {
    return Collections.emptyMap();
  }
  final Map<String,Object> toReturn=getAllProperties(b);
  a.accept(new AutoBeanVisitor(){
    @Override public boolean visitReferenceProperty(    String propertyName,    AutoBean<?> previousValue,    PropertyContext ctx){
      if (toReturn.containsKey(propertyName)) {
        if (equal(propertyName,previousValue)) {
          toReturn.remove(propertyName);
        }
      }
 else {
        toReturn.put(propertyName,null);
      }
      return false;
    }
    @Override public boolean visitValueProperty(    String propertyName,    Object previousValue,    PropertyContext ctx){
      if (toReturn.containsKey(propertyName)) {
        if (equal(propertyName,previousValue)) {
          toReturn.remove(propertyName);
        }
      }
 else {
        toReturn.put(propertyName,null);
      }
      return false;
    }
    private boolean equal(    String propertyName,    AutoBean<?> previousValue){
      return previousValue == null && toReturn.get(propertyName) == null || previousValue != null && equal(propertyName,previousValue.as());
    }
    private boolean equal(    String propertyName,    Object previousValue){
      Object currentValue=toReturn.get(propertyName);
      return previousValue == null && currentValue == null || previousValue != null && previousValue.equals(currentValue);
    }
  }
);
  return toReturn;
}

Fixed version (ground truth):
/** 
 * Returns a map of properties that differ (via   {@link Object#equals(Object)}) between two AutoBeans. The keys are property names and the values are the value of the property in <code>b</code>. Properties present in <code>a</code> but missing in <code>b</code> will be represented by <code>null</code> values. This implementation will compare AutoBeans of different parameterizations, although the diff produced is likely meaningless. <p> This will work for both simple and wrapper AutoBeans.
 * @param a an {@link AutoBean}
 * @param b an {@link AutoBean}
 * @return a {@link Map} of differing properties
 */
public static Map<String,Object> diff(AutoBean<?> a,AutoBean<?> b){
  if (a == b) {
    return Collections.emptyMap();
  }
  final Map<String,Object> toReturn=getAllProperties(b);
  a.accept(new AutoBeanVisitor(){
    @Override public boolean visitReferenceProperty(    String propertyName,    AutoBean<?> previousValue,    PropertyContext ctx){
      if (toReturn.containsKey(propertyName)) {
        if (equal(propertyName,previousValue)) {
          toReturn.remove(propertyName);
        }
      }
 else {
        toReturn.put(propertyName,null);
      }
      return false;
    }
    @Override public boolean visitValueProperty(    String propertyName,    Object previousValue,    PropertyContext ctx){
      if (toReturn.containsKey(propertyName)) {
        if (equal(propertyName,previousValue)) {
          toReturn.remove(propertyName);
        }
      }
 else {
        toReturn.put(propertyName,null);
      }
      return false;
    }
    private boolean equal(    String propertyName,    AutoBean<?> previousValue){
      return previousValue == null && toReturn.get(propertyName) == null || previousValue != null && equal(propertyName,previousValue.as());
    }
    private boolean equal(    String propertyName,    Object previousValue){
      Object currentValue=toReturn.get(propertyName);
      return previousValue == null && currentValue == null || previousValue != null && previousValue.equals(currentValue);
    }
  }
);
  return toReturn;
}