Program: 113286
Project: 113286
Buggy source:
/** 
 * @param path the full path to the feature, including its name
 * @param newRevFeature the new version of the feature
 * @param oldRevFeature the old version of the feature
 * @param newRevFeatureType the new version of the feature type
 * @param oldRevFeatureType the old version of the feature type
 * @param all - true if all attributes should be added regardless of change
 */
public FeatureDiff(String path,@Nullable RevFeature newRevFeature,@Nullable RevFeature oldRevFeature,@Nullable RevFeatureType newRevFeatureType,@Nullable RevFeatureType oldRevFeatureType,boolean all){
  this.path=path;
  this.newFeatureType=newRevFeatureType;
  this.oldFeatureType=oldRevFeatureType;
  diffs=new HashMap<PropertyDescriptor,AttributeDiff>();
  if (newRevFeature == null) {
    Preconditions.checkArgument(oldRevFeature != null,"String_Node_Str");
    Preconditions.checkArgument(oldRevFeatureType != null,"String_Node_Str");
    ImmutableList<PropertyDescriptor> oldAttributes=oldRevFeatureType.sortedDescriptors();
    ImmutableList<Optional<Object>> oldValues=oldRevFeature.getValues();
    for (int i=0; i < oldAttributes.size(); i++) {
      Optional<Object> oldValue=oldValues.get(i);
      PropertyDescriptor descriptor=oldAttributes.get(i);
      if (Geometry.class.isAssignableFrom(descriptor.getType().getBinding())) {
        diffs.put(descriptor,new GeometryAttributeDiff(Optional.fromNullable((Geometry)oldValue.orNull()),Optional.absent()));
      }
 else {
        diffs.put(oldAttributes.get(i),new GenericAttributeDiffImpl(oldValue,null));
      }
    }
  }
 else   if (oldRevFeature == null) {
    Preconditions.checkArgument(newRevFeatureType != null,"String_Node_Str");
    ImmutableList<PropertyDescriptor> newAttributes=newRevFeatureType.sortedDescriptors();
    ImmutableList<Optional<Object>> newValues=newRevFeature.getValues();
    for (int i=0; i < newAttributes.size(); i++) {
      Optional<Object> newValue=newValues.get(i);
      PropertyDescriptor descriptor=newAttributes.get(i);
      if (Geometry.class.isAssignableFrom(descriptor.getType().getBinding())) {
        diffs.put(descriptor,new GeometryAttributeDiff(Optional.absent(),Optional.fromNullable((Geometry)newValue.orNull())));
      }
 else {
        diffs.put(newAttributes.get(i),new GenericAttributeDiffImpl(null,newValue));
      }
    }
  }
 else {
    ImmutableList<PropertyDescriptor> oldAttributes=oldRevFeatureType.sortedDescriptors();
    ImmutableList<PropertyDescriptor> newAttributes=newRevFeatureType.sortedDescriptors();
    ImmutableList<Optional<Object>> oldValues=oldRevFeature.getValues();
    ImmutableList<Optional<Object>> newValues=newRevFeature.getValues();
    BitSet updatedAttributes=new BitSet(newValues.size());
    for (int i=0; i < oldAttributes.size(); i++) {
      Optional<Object> oldValue=oldValues.get(i);
      int idx=newAttributes.indexOf(oldAttributes.get(i));
      if (idx != -1) {
        Optional<Object> newValue=newValues.get(idx);
        if (!oldValue.equals(newValue) || all) {
          if (Geometry.class.isAssignableFrom(oldAttributes.get(i).getType().getBinding())) {
            diffs.put(oldAttributes.get(i),new GeometryAttributeDiff(Optional.fromNullable((Geometry)oldValue.orNull()),Optional.fromNullable((Geometry)newValue.orNull())));
          }
 else {
            diffs.put(oldAttributes.get(i),new GenericAttributeDiffImpl(oldValue,newValue));
          }
        }
        updatedAttributes.set(idx);
      }
 else {
        if (Geometry.class.isAssignableFrom(oldAttributes.get(i).getType().getBinding())) {
          diffs.put(oldAttributes.get(i),new GeometryAttributeDiff(Optional.fromNullable((Geometry)oldValue.orNull()),Optional.fromNullable((Geometry)null)));
        }
 else {
          diffs.put(oldAttributes.get(i),new GenericAttributeDiffImpl(oldValue,null));
        }
      }
    }
    updatedAttributes.flip(0,newValues.size());
    for (int i=updatedAttributes.nextSetBit(0); i >= 0; i=updatedAttributes.nextSetBit(i + 1)) {
      if (Geometry.class.isAssignableFrom(newAttributes.get(i).getType().getBinding())) {
        diffs.put(newAttributes.get(i),new GeometryAttributeDiff(Optional.fromNullable((Geometry)null),Optional.fromNullable((Geometry)newValues.get(i).orNull())));
      }
 else {
        diffs.put(newAttributes.get(i),new GenericAttributeDiffImpl(null,newValues.get(i)));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * @param path the full path to the feature, including its name
 * @param newRevFeature the new version of the feature
 * @param oldRevFeature the old version of the feature
 * @param newRevFeatureType the new version of the feature type
 * @param oldRevFeatureType the old version of the feature type
 * @param all - true if all attributes should be added regardless of change
 */
public FeatureDiff(String path,@Nullable RevFeature newRevFeature,@Nullable RevFeature oldRevFeature,@Nullable RevFeatureType newRevFeatureType,@Nullable RevFeatureType oldRevFeatureType,boolean all){
  this.path=path;
  this.newFeatureType=newRevFeatureType;
  this.oldFeatureType=oldRevFeatureType;
  diffs=new HashMap<PropertyDescriptor,AttributeDiff>();
  if (newRevFeature == null) {
    Preconditions.checkArgument(oldRevFeature != null,"String_Node_Str");
    Preconditions.checkArgument(oldRevFeatureType != null,"String_Node_Str");
    ImmutableList<PropertyDescriptor> oldAttributes=oldRevFeatureType.sortedDescriptors();
    ImmutableList<Optional<Object>> oldValues=oldRevFeature.getValues();
    for (int i=0; i < oldAttributes.size(); i++) {
      Optional<Object> oldValue=oldValues.get(i);
      PropertyDescriptor descriptor=oldAttributes.get(i);
      if (Geometry.class.isAssignableFrom(descriptor.getType().getBinding())) {
        diffs.put(descriptor,new GeometryAttributeDiff((Geometry)oldValue.orNull(),(Geometry)null));
      }
 else {
        diffs.put(oldAttributes.get(i),new GenericAttributeDiffImpl(oldValue.orNull(),null));
      }
    }
  }
 else   if (oldRevFeature == null) {
    Preconditions.checkArgument(newRevFeatureType != null,"String_Node_Str");
    ImmutableList<PropertyDescriptor> newAttributes=newRevFeatureType.sortedDescriptors();
    ImmutableList<Optional<Object>> newValues=newRevFeature.getValues();
    for (int i=0; i < newAttributes.size(); i++) {
      Optional<Object> newValue=newValues.get(i);
      PropertyDescriptor descriptor=newAttributes.get(i);
      if (Geometry.class.isAssignableFrom(descriptor.getType().getBinding())) {
        diffs.put(descriptor,new GeometryAttributeDiff((Geometry)null,(Geometry)newValue.orNull()));
      }
 else {
        diffs.put(newAttributes.get(i),new GenericAttributeDiffImpl(null,newValue.orNull()));
      }
    }
  }
 else {
    ImmutableList<PropertyDescriptor> oldAttributes=oldRevFeatureType.sortedDescriptors();
    ImmutableList<PropertyDescriptor> newAttributes=newRevFeatureType.sortedDescriptors();
    ImmutableList<Optional<Object>> oldValues=oldRevFeature.getValues();
    ImmutableList<Optional<Object>> newValues=newRevFeature.getValues();
    BitSet updatedAttributes=new BitSet(newValues.size());
    for (int i=0; i < oldAttributes.size(); i++) {
      Optional<Object> oldValue=oldValues.get(i);
      int idx=newAttributes.indexOf(oldAttributes.get(i));
      if (idx != -1) {
        Optional<Object> newValue=newValues.get(idx);
        if (!oldValue.equals(newValue) || all) {
          if (Geometry.class.isAssignableFrom(oldAttributes.get(i).getType().getBinding())) {
            diffs.put(oldAttributes.get(i),new GeometryAttributeDiff((Geometry)oldValue.orNull(),(Geometry)newValue.orNull()));
          }
 else {
            diffs.put(oldAttributes.get(i),new GenericAttributeDiffImpl(oldValue.orNull(),newValue.orNull()));
          }
        }
        updatedAttributes.set(idx);
      }
 else {
        if (Geometry.class.isAssignableFrom(oldAttributes.get(i).getType().getBinding())) {
          diffs.put(oldAttributes.get(i),new GeometryAttributeDiff((Geometry)oldValue.orNull(),(Geometry)null));
        }
 else {
          diffs.put(oldAttributes.get(i),new GenericAttributeDiffImpl(oldValue.orNull(),null));
        }
      }
    }
    updatedAttributes.flip(0,newValues.size());
    for (int i=updatedAttributes.nextSetBit(0); i >= 0; i=updatedAttributes.nextSetBit(i + 1)) {
      PropertyDescriptor descriptor=newAttributes.get(i);
      if (Geometry.class.isAssignableFrom(descriptor.getType().getBinding())) {
        diffs.put(descriptor,new GeometryAttributeDiff((Geometry)null,(Geometry)newValues.get(i).orNull()));
      }
 else {
        diffs.put(descriptor,new GenericAttributeDiffImpl(null,newValues.get(i).orNull()));
      }
    }
  }
}