nus-yam/ex-repair huggingface dataset:
Program: 56792
Project: 56792
Buggy source:
@Test public void canGoForward() throws Exception {
  PersistentList<Character> values=list('a','b','c','d','e');
  Iterator<Character> expected=values.iterator();
  ListIterator<Character> listIterator=new ZipperListIterator<Character>(zipper(values));
  for (int i=0; i < values.size(); i++) {
    System.out.println("String_Node_Str" + i);
    assertThat(listIterator.hasNext(),is(expected.hasNext()));
    assertThat(listIterator.next(),is(expected.next()));
  }
  assertThat(listIterator.hasNext(),is(expected.hasNext()));
}

Fixed version (ground truth):
@Test public void canGoForward() throws Exception {
  PersistentList<Character> values=list('a','b','c','d','e');
  Iterator<Character> expected=values.iterator();
  ListIterator<Character> listIterator=new ZipperListIterator<Character>(zipper(values));
  for (int i=0; i < values.size(); i++) {
    assertThat(listIterator.hasNext(),is(expected.hasNext()));
    assertThat(listIterator.next(),is(expected.next()));
  }
  assertThat(listIterator.hasNext(),is(expected.hasNext()));
}
Program: 56793
Project: 56793
Buggy source:
private static Operators<? extends Number> internalOperatorsFor(Class<? extends Number> numberClass){
  if (numberClass == Integer.class)   return IntegerOperators.Instance;
  if (numberClass == Long.class)   return LongOperators.Instance;
  if (numberClass == BigInteger.class)   return BigIntegerOperators.Instance;
  if (numberClass == BigDecimal.class)   return BigDecimalOperators.Instance;
  if (numberClass == Ratio.class)   return RatioOperators.Instance;
  if (numberClass == Float.class)   return FloatOperators.Instance;
  if (numberClass == Double.class)   return DoubleOperators.Instance;
  if (numberClass == Double.class)   return DoubleOperators.Instance;
  throw new UnsupportedOperationException("String_Node_Str" + numberClass);
}

Fixed version (ground truth):
private static Operators<? extends Number> internalOperatorsFor(Class<? extends Number> numberClass){
  if (numberClass == Short.class)   return ShortOperators.Instance;
  if (numberClass == Integer.class)   return IntegerOperators.Instance;
  if (numberClass == Long.class)   return LongOperators.Instance;
  if (numberClass == BigInteger.class)   return BigIntegerOperators.Instance;
  if (numberClass == BigDecimal.class)   return BigDecimalOperators.Instance;
  if (numberClass == Ratio.class)   return RatioOperators.Instance;
  if (numberClass == Float.class)   return FloatOperators.Instance;
  if (numberClass == Double.class)   return DoubleOperators.Instance;
  throw new UnsupportedOperationException("String_Node_Str" + numberClass);
}
Program: 56794
Project: 56794
Buggy source:
private void init(boolean zeroBytes) throws IOException {
  if (init) {
    ZipEntry entry=new ZipEntry(filename);
    entry.setTime(modified.getTime());
    if (zeroBytes) {
      entry.setMethod(ZipEntry.STORED);
      entry.setSize(0);
      entry.setCrc(0);
    }
    this.out.putNextEntry(entry);
  }
}

Fixed version (ground truth):
private void init(boolean zeroBytes) throws IOException {
  if (init) {
    init=false;
    ZipEntry entry=new ZipEntry(filename);
    entry.setTime(modified.getTime());
    if (zeroBytes) {
      entry.setMethod(ZipEntry.STORED);
      entry.setSize(0);
      entry.setCrc(0);
    }
    this.out.putNextEntry(entry);
  }
}
Program: 56795
Project: 56795
Buggy source:
@Test public void shouldFailIfAllValidatorsFail(){
  Validator<String> validator=validateThat(is("String_Node_Str")).or(validateThat(is("String_Node_Str"))).assigningFailuresTo("String_Node_Str");
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),hasExactly(AnyOfValidator.DEFAULT_MESSAGE));
}

Fixed version (ground truth):
@Test public void shouldFailIfAllValidatorsFail(){
  LogicalValidator<String> validator=validateThat(is("String_Node_Str")).or(validateThat(is("String_Node_Str"))).assigningFailuresTo("String_Node_Str");
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),hasExactly(AnyOfValidator.DEFAULT_MESSAGE));
}
Program: 56796
Project: 56796
Buggy source:
@Test public void shouldPassIfAnyValidatorPasses(){
  Validator<String> validator=validateThat(is("String_Node_Str")).or(validateThat(is("String_Node_Str"))).assigningFailuresTo("String_Node_Str");
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),isEmpty(String.class));
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),isEmpty(String.class));
}

Fixed version (ground truth):
@Test public void shouldPassIfAnyValidatorPasses(){
  LogicalValidator<String> validator=validateThat(is("String_Node_Str")).or(validateThat(is("String_Node_Str"))).assigningFailuresTo("String_Node_Str");
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),isEmpty(String.class));
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),isEmpty(String.class));
}
Program: 56797
Project: 56797
Buggy source:
@Test public void shouldFailIfAllValidatorsFail(){
  LogicalValidator<String> validator=validateThat(is("String_Node_Str")).or(validateThat(is("String_Node_Str"))).assigningFailuresTo("String_Node_Str");
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),hasExactly(AnyOfValidator.DEFAULT_MESSAGE));
}

Fixed version (ground truth):
@Test public void shouldFailIfAllValidatorsFail(){
  LogicalValidator<String> validator=validateThat(is("String_Node_Str")).or(validateThat(is("String_Node_Str"))).assigningFailuresTo("String_Node_Str").castValidator();
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),hasExactly(AnyOfValidator.DEFAULT_MESSAGE));
}
Program: 56798
Project: 56798
Buggy source:
@Test public void shouldPassIfAnyValidatorPasses(){
  LogicalValidator<String> validator=validateThat(is("String_Node_Str")).or(validateThat(is("String_Node_Str"))).assigningFailuresTo("String_Node_Str");
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),isEmpty(String.class));
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),isEmpty(String.class));
}

Fixed version (ground truth):
@Test public void shouldPassIfAnyValidatorPasses(){
  LogicalValidator<String> validator=validateThat(is("String_Node_Str")).or(validateThat(is("String_Node_Str"))).assigningFailuresTo("String_Node_Str").castValidator();
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),isEmpty(String.class));
  assertThat(validator.validate("String_Node_Str").messages("String_Node_Str"),isEmpty(String.class));
}
Program: 56799
Project: 56799
Buggy source:
private Integer daysBetween(Date start,Date end){
  return abs((int)(end.getTime() - start.getTime())) / (24 * 60 * 60* 1000);
}

Fixed version (ground truth):
private int daysBetween(Date start,Date end){
  return (int)abs((end.getTime() - start.getTime()) / 1000);
}
Program: 56800
Project: 56800
Buggy source:
@Override protected Date getNext() throws Exception {
  return stripTime(Days.add(bounds.first(),between(0,daysBetween(bounds.first(),bounds.second())).head()));
}

Fixed version (ground truth):
@Override protected Date getNext() throws Exception {
  return Seconds.add(bounds.first(),between(0,daysBetween(bounds.first(),bounds.second())).head());
}
Program: 56801
Project: 56801
Buggy source:
public static Sequence<Date> between(final Date start,final Date end){
  final Pair<Date,Date> bounds=bounds(start,end);
  return Sequences.forwardOnly(new StatefulIterator<Date>(){
    @Override protected Date getNext() throws Exception {
      return stripTime(Days.add(bounds.first(),between(0,daysBetween(bounds.first(),bounds.second())).head()));
    }
    private Integer daysBetween(    Date start,    Date end){
      return abs((int)(end.getTime() - start.getTime())) / (24 * 60 * 60* 1000);
    }
  }
);
}

Fixed version (ground truth):
public static Sequence<Date> between(final Date start,final Date end){
  final Pair<Date,Date> bounds=bounds(start,end);
  return Sequences.forwardOnly(new StatefulIterator<Date>(){
    @Override protected Date getNext() throws Exception {
      return Seconds.add(bounds.first(),between(0,daysBetween(bounds.first(),bounds.second())).head());
    }
    private int daysBetween(    Date start,    Date end){
      return (int)abs((end.getTime() - start.getTime()) / 1000);
    }
  }
);
}
Program: 56802
Project: 56802
Buggy source:
@Test public void betweenDates(){
  Date yesterday=Days.subtract(NOW,1);
  Date tomorrow=Days.add(NOW,1);
  assertThat(Randoms.between(yesterday,tomorrow).take(TESTS),matcher(Predicates.<Date>forAll(between(yesterday,tomorrow))));
  assertThat(Randoms.between(tomorrow,yesterday).take(TESTS),matcher(Predicates.<Date>forAll(between(yesterday,tomorrow))));
  assertThat(Randoms.between(NOW,NOW).take(TESTS),matcher(Predicates.<Date>forAll(between(NOW,NOW))));
}

Fixed version (ground truth):
@Test public void betweenDates(){
  Date yesterday=Days.subtract(NOW,1);
  Date theFuture=Dates.MAX_VALUE;
  assertThat(Randoms.between(yesterday,theFuture).take(TESTS),matcher(Predicates.<Date>forAll(between(yesterday,theFuture))));
  assertThat(Randoms.between(theFuture,yesterday).take(TESTS),matcher(Predicates.<Date>forAll(between(yesterday,theFuture))));
  assertThat(Randoms.between(NOW,NOW).take(TESTS),matcher(Predicates.<Date>forAll(between(NOW,NOW))));
}
Program: 56803
Project: 56803
Buggy source:
@Override public Number identity(){
  return weighted(0);
}

Fixed version (ground truth):
@Override public Number identity(){
  return weighted(0,0);
}
Program: 56804
Project: 56804
Buggy source:
public static Weighted weighted(Number number){
  if (number instanceof Weighted)   return (Weighted)number;
  return weighted(number,isZero(number) ? 0 : 1);
}

Fixed version (ground truth):
public static Weighted weighted(Number number){
  if (number instanceof Weighted)   return (Weighted)number;
  return weighted(number,1);
}
Program: 56805
Project: 56805
Buggy source:
@Test public void supportsAverage() throws Exception {
  assertThat(numbers(1,2,3,4).reduce(average),NumberMatcher.is(divide(5,2)));
  assertThat(numbers(1,2,3).reduce(average),NumberMatcher.is(2));
  assertThat(numbers(1,2).reduce(average),NumberMatcher.is(1.5));
  assertThat(numbers(1).reduce(average),NumberMatcher.is(1));
  assertThat(numbers().reduce(average),NumberMatcher.is(0));
}

Fixed version (ground truth):
@Test public void supportsAverage() throws Exception {
  assertThat(numbers(1,2,3,4).reduce(average),NumberMatcher.is(divide(5,2)));
  assertThat(numbers(1,2,3).reduce(average),NumberMatcher.is(2));
  assertThat(numbers(1,2).reduce(average),NumberMatcher.is(1.5));
  assertThat(numbers(1,0).reduce(average),NumberMatcher.is(.5));
  assertThat(numbers(1).reduce(average),NumberMatcher.is(1));
  assertThat(numbers().reduce(average),NumberMatcher.is(0));
}
Program: 56806
Project: 56806
Buggy source:
public int compare(T m1,T m2){
  for (  Comparator<? super T> comparator : comparators) {
    int comparisonResult=comparator.compare(m1,m2);
    if (comparisonResult != 0)     return comparisonResult;
  }
  return 0;
}

Fixed version (ground truth):
public int compare(Comparable a,Comparable b){
  return b.compareTo(a);
}
Program: 56807
Project: 56807
Buggy source:
@Override public boolean equals(Object o){
  return o instanceof Left && ((Left)o).value.equals(value);
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  return o instanceof Left && equalTo(((Left)o).value,value);
}
Program: 56808
Project: 56808
Buggy source:
@Override public boolean equals(Object o){
  return o instanceof Right && ((Right)o).value.equals(value);
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  return o instanceof Right && equalTo(((Right)o).value,value);
}
Program: 56809
Project: 56809
Buggy source:
public static <T,S>Sequence<T> unique(final Iterable<? extends T> iterable,final Callable1<? super T,? extends S> callable){
  return sequence(iterable).filter(new UniquePredicate<T,S>(callable));
}

Fixed version (ground truth):
public static <T,S>Sequence<T> unique(final Iterable<? extends T> iterable,final Callable1<? super T,? extends S> callable){
  return new Sequence<T>(){
    @Override public Iterator<T> iterator(){
      return Iterators.filter(iterable.iterator(),new UniquePredicate<T,S>(callable));
    }
  }
;
}
Program: 56810
Project: 56810
Buggy source:
public void checkin(){
  checkoutCount--;
}

Fixed version (ground truth):
public int checkin(){
  return --checkoutCount;
}
Program: 56811
Project: 56811
Buggy source:
public static <T>LogicalPredicate<T> instanceOf(final Class t){
  return new InstanceOf<T>(t);
}

Fixed version (ground truth):
public static <T>LogicalPredicate<T> instanceOf(final Class<?> t){
  return new InstanceOf<T>(t);
}
Program: 56812
Project: 56812
Buggy source:
public static LogicalPredicate<Object> assignableTo(final Class aClass){
  return new LogicalPredicate<Object>(){
    public boolean matches(    Object o){
      return isAssignableTo(o,aClass);
    }
  }
;
}

Fixed version (ground truth):
public static LogicalPredicate<Object> assignableTo(final Class<?> aClass){
  return new LogicalPredicate<Object>(){
    public boolean matches(    Object o){
      return isAssignableTo(o,aClass);
    }
  }
;
}
Program: 56813
Project: 56813
Buggy source:
public static boolean isAssignableTo(Object o,Class aClass){
  if (o == null)   return false;
  return aClass.isAssignableFrom(o.getClass());
}

Fixed version (ground truth):
public static boolean isAssignableTo(Object o,Class<?> aClass){
  if (o == null)   return false;
  return aClass.isAssignableFrom(o.getClass());
}
Program: 56814
Project: 56814
Buggy source:
public final int compareTo(Object o){
  Number other=(Number)o;
  return Numbers.compare(this,other);
}

Fixed version (ground truth):
public final int compareTo(Number other){
  return Numbers.compare(this,other);
}
Program: 56815
Project: 56815
Buggy source:
public static <T>Class<T> getGenericSuperclassType(Class aClass,int index){
  ParameterizedType type=(ParameterizedType)aClass.getGenericSuperclass();
  Type[] actualTypeArguments=type.getActualTypeArguments();
  return (Class<T>)actualTypeArguments[index];
}

Fixed version (ground truth):
public static <T>Class<T> getGenericSuperclassType(Class<?> aClass,int index){
  ParameterizedType type=(ParameterizedType)aClass.getGenericSuperclass();
  Type[] actualTypeArguments=type.getActualTypeArguments();
  return (Class<T>)actualTypeArguments[index];
}
Program: 56816
Project: 56816
Buggy source:
public static <T>T createProxy(Class<T> aCLass,InvocationHandler invocationHandler){
  return (T)new Proxy().createInstance(aCLass,invocationHandler);
}

Fixed version (ground truth):
public static <T>T createProxy(Class<T> aCLass,InvocationHandler invocationHandler){
  return new Proxy().createInstance(aCLass,invocationHandler);
}
Program: 56817
Project: 56817
Buggy source:
public Object createInstance(final Class aClass,final Callback invocationHandler){
  Callback[] callbacks={invocationHandler,NoOp.INSTANCE};
  ObjectInstantiator instantiator=get(aClass,callbacks);
  Object instance=instantiator.newInstance();
  Factory factory=(Factory)instance;
  factory.setCallbacks(callbacks);
  return instance;
}

Fixed version (ground truth):
public <T>T createInstance(final Class<T> aClass,final Callback invocationHandler){
  Callback[] callbacks={invocationHandler,NoOp.INSTANCE};
  ObjectInstantiator instantiator=get(aClass,callbacks);
  Object instance=instantiator.newInstance();
  Factory factory=(Factory)instance;
  factory.setCallbacks(callbacks);
  return (T)instance;
}
Program: 56818
Project: 56818
Buggy source:
private ObjectInstantiator get(final Class aClass,final Callback[] callbacks){
synchronized (cache) {
    if (!cache.containsKey(aClass)) {
      cache.put(aClass,createInstantiator(aClass,callbacks));
    }
    return cache.get(aClass);
  }
}

Fixed version (ground truth):
private ObjectInstantiator get(final Class<?> aClass,final Callback[] callbacks){
synchronized (cache) {
    if (!cache.containsKey(aClass)) {
      cache.put(aClass,createInstantiator(aClass,callbacks));
    }
    return cache.get(aClass);
  }
}
Program: 56819
Project: 56819
Buggy source:
private ObjectInstantiator createInstantiator(Class aClass,Callback[] callbacks){
  IgnoreConstructorsEnhancer enhancer=new IgnoreConstructorsEnhancer();
  enhancer.setSuperclass(aClass);
  enhancer.setCallbackTypes(sequence(callbacks).map(toClass()).toArray(Class.class));
  enhancer.setCallbackFilter(new ToStringFilter());
  enhancer.setUseFactory(true);
  Class enhancedClass=enhancer.createClass();
  return objenesis.getInstantiatorOf(enhancedClass);
}

Fixed version (ground truth):
private ObjectInstantiator createInstantiator(Class<?> aClass,Callback[] callbacks){
  IgnoreConstructorsEnhancer enhancer=new IgnoreConstructorsEnhancer();
  enhancer.setSuperclass(aClass);
  enhancer.setCallbackTypes(sequence(callbacks).map(toClass()).toArray(Class.class));
  enhancer.setCallbackFilter(new ToStringFilter());
  enhancer.setUseFactory(true);
  Class enhancedClass=enhancer.createClass();
  return objenesis.getInstantiatorOf(enhancedClass);
}
Program: 56820
Project: 56820
Buggy source:
@Override public Number remove(Keyword recordName){
  Record head=get(recordName).map(SelectCallable.select(Keywords.keyword("String_Node_Str",String.class))).head();
  Number result=Numbers.valueOf(head.get(Keywords.keyword("String_Node_Str",String.class)));
  List<Keyword<?>> undefine=undefine(recordName);
  define(recordName,undefine.toArray(new Keyword[0]));
  return result;
}

Fixed version (ground truth):
@Override public Number remove(Keyword recordName){
  Record head=get(recordName).map(select(Keywords.keyword("String_Node_Str",String.class))).head();
  Number result=Numbers.valueOf(head.get(Keywords.keyword("String_Node_Str",String.class)));
  List<Keyword<?>> undefine=undefine(recordName);
  define(recordName,undefine.toArray(new Keyword[0]));
  return result;
}
Program: 56821
Project: 56821
Buggy source:
public static SetFunctionType setFunctionType(Callable2<?,?,?> callable,Keyword column){
  return new SetFunctionType(callable,column);
}

Fixed version (ground truth):
public static SetFunctionType setFunctionType(Callable2<?,?,?> callable,Keyword<?> column){
  return new SetFunctionType(callable,column);
}
Program: 56822
Project: 56822
Buggy source:
public static String functionName(final Class<? extends Callable2> aClass,Keyword column){
  if (!names.containsKey(aClass)) {
    throw new UnsupportedOperationException();
  }
  return format("String_Node_Str",names.get(aClass),column);
}

Fixed version (ground truth):
public static String functionName(final Class<? extends Callable2> aClass,Keyword<?> column){
  if (!names.containsKey(aClass)) {
    throw new UnsupportedOperationException();
  }
  return format("String_Node_Str",names.get(aClass),column);
}
Program: 56823
Project: 56823
Buggy source:
public SetFunctionType(Callable2<?,?,?> callable,Keyword column){
  super(functionName(callable.getClass(),column));
}

Fixed version (ground truth):
public SetFunctionType(Callable2<?,?,?> callable,Keyword<?> column){
  super(functionName(callable.getClass(),column));
}
Program: 56824
Project: 56824
Buggy source:
@Override protected boolean matchesSafely(Iterable iterable){
  return size.equals(sequence(iterable).size());
}

Fixed version (ground truth):
@Override protected boolean matchesSafely(Iterable<T> iterable){
  return size.equals(sequence(iterable).size());
}
Program: 56825
Project: 56825
Buggy source:
public Object invoke(Object proxy,Method method,Object[] arguments) throws Throwable {
  invocation.set(new Invocation(proxy,method,arguments));
  return null;
}

Fixed version (ground truth):
public Object invoke(Object proxy,Method method,Object[] arguments) throws Throwable {
  invocation.set(new Invocation<T,R>(proxy,method,arguments));
  return null;
}
Program: 56826
Project: 56826
Buggy source:
public S call(T t) throws Exception {
  return (S)invocation.call(t);
}

Fixed version (ground truth):
public S call(T t) throws Exception {
  return invocation.call(t);
}
Program: 56827
Project: 56827
Buggy source:
public Invocation invocation(){
  return invocation;
}

Fixed version (ground truth):
public Invocation<T,S> invocation(){
  return invocation;
}
Program: 56828
Project: 56828
Buggy source:
public Object invoke(Object proxy,Method method,Object[] arguments) throws Throwable {
  invocation=new Invocation(proxy,method,arguments);
  return null;
}

Fixed version (ground truth):
public Object invoke(Object proxy,Method method,Object[] arguments) throws Throwable {
  invocation=new Invocation<T,S>(proxy,method,arguments);
  return null;
}
Program: 56829
Project: 56829
Buggy source:
@Override public void set(Invocation value){
  if (get() != null) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  super.set(value);
}

Fixed version (ground truth):
@Override public void set(Invocation<T,R> value){
  if (get() != null) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  super.set(value);
}
Program: 56830
Project: 56830
Buggy source:
@Override public Invocation get(){
  final Invocation result=super.get();
  super.set(null);
  return result;
}

Fixed version (ground truth):
@Override public Invocation<T,R> get(){
  final Invocation<T,R> result=super.get();
  super.set(null);
  return result;
}
Program: 56831
Project: 56831
Buggy source:
@Test public void canSortByProxy() throws Exception {
  User matt=user("String_Node_Str","String_Node_Str");
  User dan=user("String_Node_Str","String_Node_Str");
  User bob=user("String_Node_Str","String_Node_Str");
  Sequence<User> unsorted=sequence(matt,dan,bob);
  Sequence<User> sorted=unsorted.sortBy(Call.<User,String>method(on(User.class).firstName()));
  assertThat(sorted,hasExactly(bob,dan,matt));
}

Fixed version (ground truth):
@Test public void canSortByProxy() throws Exception {
  User matt=user("String_Node_Str","String_Node_Str");
  User dan=user("String_Node_Str","String_Node_Str");
  User bob=user("String_Node_Str","String_Node_Str");
  Sequence<User> unsorted=sequence(matt,dan,bob);
  Sequence<User> sorted=unsorted.sortBy(method(on(User.class).firstName()));
  assertThat(sorted,hasExactly(bob,dan,matt));
}
Program: 56832
Project: 56832
Buggy source:
public void define(Keyword recordName,Keyword<?>... fields){
  memory.put(recordName,new ArrayList<Record>());
}

Fixed version (ground truth):
public void define(Keyword recordName,Keyword<?>... fields){
}
Program: 56833
Project: 56833
Buggy source:
private List<Record> recordsFor(Keyword recordName){
  return memory.get(recordName);
}

Fixed version (ground truth):
private List<Record> recordsFor(Keyword recordName){
  if (!memory.containsKey(recordName)) {
    memory.put(recordName,new ArrayList<Record>());
  }
  return memory.get(recordName);
}
Program: 56834
Project: 56834
Buggy source:
public Number remove(Keyword recordName){
  int count=memory.get(recordName).size();
  recordsFor(recordName).clear();
  return count;
}

Fixed version (ground truth):
public Number remove(Keyword recordName){
  List<Record> records=recordsFor(recordName);
  int count=records.size();
  memory.remove(recordName);
  return count;
}
Program: 56835
Project: 56835
Buggy source:
public Number add(Keyword recordName,Sequence<Keyword> fields,Sequence<Record> records){
  if (records.isEmpty()) {
    return 0;
  }
  List<Record> list=getRecordsFor(recordName);
  Number count=0;
  for (  Record record : records.map(select(fields))) {
    list.add(record);
    count=increment(count);
  }
  return count;
}

Fixed version (ground truth):
public Number add(Keyword recordName,Sequence<Keyword> fields,Sequence<Record> records){
  if (records.isEmpty()) {
    return 0;
  }
  List<Record> list=recordsFor(recordName);
  Number count=0;
  for (  Record record : records.map(select(fields))) {
    list.add(record);
    count=increment(count);
  }
  return count;
}
Program: 56836
Project: 56836
Buggy source:
@SuppressWarnings({"String_Node_Str"}) public Number set(Keyword recordName,Predicate<? super Record> predicate,Sequence<Keyword> fields,Record record){
  List<Record> records=getRecordsFor(recordName);
  Number count=0;
  Sequence<Integer> indexes=get(recordName).zipWithIndex().filter(where(second(Record.class),is(predicate))).map(first(Number.class)).safeCast(Integer.class);
  for (  Integer index : indexes) {
    records.set(index,record.fields().fold(records.get(index),updateValues()));
  }
  count=Numbers.add(count,indexes.size());
  return count;
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str"}) public Number set(Keyword recordName,Predicate<? super Record> predicate,Sequence<Keyword> fields,Record record){
  List<Record> records=recordsFor(recordName);
  Number count=0;
  Sequence<Integer> indexes=get(recordName).zipWithIndex().filter(where(second(Record.class),is(predicate))).map(first(Number.class)).safeCast(Integer.class);
  for (  Integer index : indexes) {
    records.set(index,record.fields().fold(records.get(index),updateValues()));
  }
  count=Numbers.add(count,indexes.size());
  return count;
}
Program: 56837
Project: 56837
Buggy source:
public Sequence<Record> get(Keyword recordName){
  return sequence(getRecordsFor(recordName));
}

Fixed version (ground truth):
public Sequence<Record> get(Keyword recordName){
  return sequence(recordsFor(recordName));
}
Program: 56838
Project: 56838
Buggy source:
public void define(Keyword recordName,Keyword<?>... fields){
}

Fixed version (ground truth):
public void define(Keyword recordName,Keyword<?>... fields){
  memory.put(recordName,new ArrayList<Record>());
}
Program: 56839
Project: 56839
Buggy source:
public Number remove(Keyword recordName){
  int count=memory.get(recordName).size();
  memory.remove(recordName);
  return count;
}

Fixed version (ground truth):
public Number remove(Keyword recordName){
  int count=memory.get(recordName).size();
  recordsFor(recordName).clear();
  return count;
}
Program: 56840
Project: 56840
Buggy source:
@Test public void supportsRemove() throws Exception {
  assertThat(records.remove(user,where(age,is(greaterThan(10)))),equalTo(2));
  assertThat(records.remove(user,where(age,is(greaterThan(10)))),equalTo(0));
  assertThat(records.get(user).size(),equalTo(1));
  assertThat(records.remove(user),equalTo(1));
  assertThat(records.get(user).size(),equalTo(0));
  addUsers(records);
}

Fixed version (ground truth):
@Test public void supportsRemove() throws Exception {
  assertThat(records.remove(user,where(age,is(greaterThan(10)))),equalTo(2));
  assertThat(records.remove(user,where(age,is(greaterThan(10)))),equalTo(0));
  assertThat(records.get(user).size(),equalTo(1));
  assertThat(records.remove(user),equalTo(1));
  Sequence<Record> recordSequence=records.get(user);
  assertThat(recordSequence.size(),equalTo(0));
  addUsers(records);
}
Program: 56841
Project: 56841
Buggy source:
@BeforeClass public static void createRecords() throws SQLException {
  AbstractRecordsTests.addRecords(new SqlRecords(getConnection("String_Node_Str","String_Node_Str","String_Node_Str")));
}

Fixed version (ground truth):
@BeforeClass public static void createRecords() throws SQLException {
  addRecords(new SqlRecords(getConnection("String_Node_Str","String_Node_Str","String_Node_Str")));
}
Program: 56842
Project: 56842
Buggy source:
public static <K,V>HashMap<K,V> map(Class<K> key,Class<V> value,Pair<K,V>... entries){
  return map(entries);
}

Fixed version (ground truth):
public static <K,V>HashMap<K,V> map(Class<K> key,Class<V> value,Pair<? extends K,? extends V>... entries){
  return map(entries);
}
Program: 56843
Project: 56843
Buggy source:
public static <K,V>HashMap<K,V> map(Class<K> key,Class<V> value,Pair<K,V>... entries){
  return map(entries);
}

Fixed version (ground truth):
public static <K,V>HashMap<K,V> map(Class<K> key,Class<V> value,Pair<? extends K,? extends V>... entries){
  return map(entries);
}
Program: 56844
Project: 56844
Buggy source:
public Number add(Keyword recordName,Sequence<Record> records){
  return add(recordName,records.first().keywords(),records);
}

Fixed version (ground truth):
public Number add(Keyword recordName,Sequence<Record> records){
  if (records.isEmpty())   return 0;
  return add(recordName,records.first().keywords(),records);
}
Program: 56845
Project: 56845
Buggy source:
public static <T>Iterator<T> remove(final Iterator<T> iterator,final T t){
  return filter(iterator,not(t));
}

Fixed version (ground truth):
public static <T>Iterator<T> remove(final Iterator<T> iterator,final T t){
  return filter(iterator,not(onlyOnce(is(t))));
}
Program: 56846
Project: 56846
Buggy source:
@Test public void supportsRemove() throws Exception {
  final Sequence<Integer> numbers=sequence(1,2,3).remove(2);
  assertThat(numbers,hasExactly(1,3));
}

Fixed version (ground truth):
@Test public void supportsRemove() throws Exception {
  final Sequence<Integer> numbers=sequence(1,2,3,2).remove(2);
  assertThat(numbers,hasExactly(1,3,2));
}
Program: 56847
Project: 56847
Buggy source:
@Override public void execute(InterpretContext ctx) throws InterpretException {
  JetWriter os=ctx.getWriter();
  if (encoder == null) {
    if (os.isStreaming()) {
      encoder=new ByteArrayEncoder(text,os.getCharset());
    }
 else {
      if (JdkUtils.IS_AT_LEAST_JAVA_7) {
        encoder=new Jdk7CharArrayEncoder(text);
      }
 else {
        encoder=new Jdk6CharArrayEncoder(text);
      }
    }
    text=null;
  }
  try {
    encoder.writeTo(os);
  }
 catch (  IOException e) {
    throw new IllegalStateException(e);
  }
}

Fixed version (ground truth):
@Override public void execute(InterpretContext ctx) throws InterpretException {
  JetWriter os=ctx.getWriter();
  if (encoder == null) {
synchronized (this) {
      if (encoder == null) {
        if (os.isStreaming()) {
          encoder=new ByteArrayEncoder(text,os.getCharset());
        }
 else {
          if (JdkUtils.IS_AT_LEAST_JAVA_7) {
            encoder=new Jdk7CharArrayEncoder(text);
          }
 else {
            encoder=new Jdk6CharArrayEncoder(text);
          }
        }
        text=null;
      }
    }
  }
  try {
    encoder.writeTo(os);
  }
 catch (  IOException e) {
    throw new IllegalStateException(e);
  }
}
Program: 56848
Project: 56848
Buggy source:
private void mergeConfigs(Properties props){
  for (  String key : DEFAULT_CONFIGS.keySet()) {
    if (props.containsKey(key) == false) {
      String value=DEFAULT_CONFIGS.get(key);
      props.put(key,value);
    }
  }
}

Fixed version (ground truth):
private void mergeConfigs(JetTemplateProperties properties){
  if (properties.getConfig() == null) {
    properties.setConfig(new Properties());
  }
  for (  String key : DEFAULT_CONFIGS.keySet()) {
    if (properties.getConfig().containsKey(key) == false) {
      String value=DEFAULT_CONFIGS.get(key);
      properties.getConfig().put(key,value);
    }
  }
}
Program: 56849
Project: 56849
Buggy source:
@Bean @ConditionalOnMissingBean(JetTemplateViewResolver.class) public JetTemplateViewResolver jetTemplateViewResolver(JetTemplateProperties properties){
  mergeConfigs(properties.getConfig());
  JetTemplateViewResolver resolver=new JetTemplateViewResolver();
  resolver.setPrefix(properties.getPrefix());
  resolver.setSuffix(properties.getSuffix());
  resolver.setCache(properties.isCache());
  resolver.setViewNames(properties.getViewNames());
  resolver.setContentType(properties.getContentType().toString());
  resolver.setOrder(properties.getOrder());
  resolver.setConfigProperties(properties.getConfig());
  resolver.setConfigLocation(properties.getConfigLocation());
  return resolver;
}

Fixed version (ground truth):
@Bean @ConditionalOnMissingBean(JetTemplateViewResolver.class) public JetTemplateViewResolver jetTemplateViewResolver(JetTemplateProperties properties){
  mergeConfigs(properties);
  JetTemplateViewResolver resolver=new JetTemplateViewResolver();
  resolver.setPrefix(properties.getPrefix());
  resolver.setSuffix(properties.getSuffix());
  resolver.setCache(properties.isCache());
  resolver.setViewNames(properties.getViewNames());
  resolver.setContentType(properties.getContentType().toString());
  resolver.setOrder(properties.getOrder());
  resolver.setConfigProperties(properties.getConfig());
  resolver.setConfigLocation(properties.getConfigLocation());
  return resolver;
}
Program: 56850
Project: 56850
Buggy source:
@Override public Object execute(InterpretContext ctx) throws InterpretException {
  Object o1=lhs.execute(ctx);
  Object o2=(rhs != null) ? rhs.execute(ctx) : null;
  Object value;
switch (operator) {
case Tokens.IDENTICALLY_EQUAL:
    value=(o1 == o2);
  break;
case Tokens.IDENTICALLY_EQUAL_NOT:
value=(o1 != o2);
break;
case Tokens.EQ:
value=ALU.equals(o1,o2);
break;
case Tokens.NE:
value=ALU.equals(o1,o2).booleanValue() ? Boolean.FALSE : Boolean.TRUE;
break;
case Tokens.AND:
value=ALU.isTrue(o1) && ALU.isTrue(o2) ? Boolean.TRUE : Boolean.FALSE;
break;
case Tokens.OR:
value=ALU.isTrue(o1) || ALU.isTrue(o2) ? Boolean.TRUE : Boolean.FALSE;
break;
case Tokens.NOT:
value=ALU.isTrue(o1) ? Boolean.FALSE : Boolean.TRUE;
break;
default :
throw new UnsupportedOperationException();
}
return value;
}

Fixed version (ground truth):
@Override public Object execute(InterpretContext ctx) throws InterpretException {
  Object o1=lhs.execute(ctx);
  Object value;
switch (operator) {
case Tokens.IDENTICALLY_EQUAL:
    value=(o1 == rhs.execute(ctx));
  break;
case Tokens.IDENTICALLY_EQUAL_NOT:
value=(o1 != rhs.execute(ctx));
break;
case Tokens.EQ:
value=ALU.equals(o1,rhs.execute(ctx));
break;
case Tokens.NE:
value=ALU.equals(o1,rhs.execute(ctx)).booleanValue() ? Boolean.FALSE : Boolean.TRUE;
break;
case Tokens.AND:
value=ALU.isTrue(o1) && ALU.isTrue(rhs.execute(ctx)) ? Boolean.TRUE : Boolean.FALSE;
break;
case Tokens.OR:
value=ALU.isTrue(o1) || ALU.isTrue(rhs.execute(ctx)) ? Boolean.TRUE : Boolean.FALSE;
break;
case Tokens.NOT:
value=ALU.isTrue(o1) ? Boolean.FALSE : Boolean.TRUE;
break;
default :
throw new UnsupportedOperationException();
}
return value;
}
Program: 56852
Project: 56852
Buggy source:
private boolean isAstDirective(AstNode node){
  return (node instanceof AstDirective) && !(node instanceof AstDirectiveInclude || node instanceof AstDirectiveCall);
}

Fixed version (ground truth):
private boolean isAstDirective(AstNode node,boolean includeInlineDirective){
  if (node instanceof AstDirective) {
    if (includeInlineDirective) {
      return true;
    }
    return !(node instanceof AstDirectiveInclude || node instanceof AstDirectiveCall);
  }
  return false;
}
Program: 56853
Project: 56853
Buggy source:
@Override public Object execute(InterpretContext ctx) throws InterpretException {
  Object o1=lhs.execute(ctx);
  Object o2=rhs.execute(ctx);
  if (o1 == null) {
    if (o2 instanceof String) {
      return o2;
    }
    throw new InterpretException(Errors.EXPRESSION_LHS_IS_NULL).set(lhs.getPosition());
  }
  if (o2 == null) {
    if (o1 instanceof String) {
      return o1;
    }
    throw new InterpretException(Errors.EXPRESSION_RHS_IS_NULL).set(lhs.getPosition());
  }
  try {
    Object value;
switch (operator) {
case Tokens.PLUS:
      value=ALU.plus(o1,o2);
    break;
case Tokens.MINUS:
  value=ALU.minus(o1,o2);
break;
case Tokens.MUL:
value=ALU.mul(o1,o2);
break;
case Tokens.DIV:
value=ALU.div(o1,o2);
break;
case Tokens.MOD:
value=ALU.mod(o1,o2);
break;
case Tokens.BIT_AND:
value=ALU.bitAnd(o1,o2);
break;
case Tokens.BIT_OR:
value=ALU.bitOr(o1,o2);
break;
case Tokens.BIT_XOR:
value=ALU.bitXor(o1,o2);
break;
case Tokens.BIT_SHL:
value=ALU.shl(o1,o2);
break;
case Tokens.BIT_SHR:
value=ALU.shr(o1,o2);
break;
case Tokens.BIT_USHR:
value=ALU.ushr(o1,o2);
break;
case Tokens.LT:
value=ALU.lt(o1,o2);
break;
case Tokens.LE:
value=ALU.le(o1,o2);
break;
case Tokens.GT:
value=ALU.gt(o1,o2);
break;
case Tokens.GE:
value=ALU.ge(o1,o2);
break;
default :
throw new UnsupportedOperationException();
}
return value;
}
 catch (IllegalStateException e) {
throw new InterpretException(e).set(position);
}
}

Fixed version (ground truth):
@Override public Object execute(InterpretContext ctx) throws InterpretException {
  Object o1=lhs.execute(ctx);
  Object o2=rhs.execute(ctx);
  if (o1 == null) {
    if (o2 instanceof String && operator == Tokens.PLUS) {
      return o2;
    }
    throw new InterpretException(Errors.EXPRESSION_LHS_IS_NULL).set(lhs.getPosition());
  }
  if (o2 == null) {
    if (o1 instanceof String && operator == Tokens.PLUS) {
      return o1;
    }
    throw new InterpretException(Errors.EXPRESSION_RHS_IS_NULL).set(rhs.getPosition());
  }
  try {
    Object value;
switch (operator) {
case Tokens.PLUS:
      value=ALU.plus(o1,o2);
    break;
case Tokens.MINUS:
  value=ALU.minus(o1,o2);
break;
case Tokens.MUL:
value=ALU.mul(o1,o2);
break;
case Tokens.DIV:
value=ALU.div(o1,o2);
break;
case Tokens.MOD:
value=ALU.mod(o1,o2);
break;
case Tokens.BIT_AND:
value=ALU.bitAnd(o1,o2);
break;
case Tokens.BIT_OR:
value=ALU.bitOr(o1,o2);
break;
case Tokens.BIT_XOR:
value=ALU.bitXor(o1,o2);
break;
case Tokens.BIT_SHL:
value=ALU.shl(o1,o2);
break;
case Tokens.BIT_SHR:
value=ALU.shr(o1,o2);
break;
case Tokens.BIT_USHR:
value=ALU.ushr(o1,o2);
break;
case Tokens.LT:
value=ALU.lt(o1,o2);
break;
case Tokens.LE:
value=ALU.le(o1,o2);
break;
case Tokens.GT:
value=ALU.gt(o1,o2);
break;
case Tokens.GE:
value=ALU.ge(o1,o2);
break;
default :
throw new UnsupportedOperationException();
}
return value;
}
 catch (IllegalStateException e) {
throw new InterpretException(e).set(position);
}
}
Program: 56854
Project: 56854
Buggy source:
/** 
 * 生成方法调用的实际参数
 */
public static Object[] getActualArguments(Object[] arguments,int actualLength,boolean isVarArgs,int offset){
  if (isVarArgs) {
    Object[] args=new Object[actualLength];
    int fixedArgsLen=actualLength - offset - 1;
    if (fixedArgsLen > 0) {
      System.arraycopy(arguments,0,args,offset,fixedArgsLen);
    }
    int varArgsLen=arguments.length - fixedArgsLen;
    if (varArgsLen == 0) {
      args[actualLength - 1]=ArrayUtils.EMPTY_OBJECT_ARRAY;
    }
 else {
      Object[] varArgs=null;
      if (varArgsLen == 1) {
        Object arg=arguments[fixedArgsLen];
        if (arg == null) {
          varArgs=ArrayUtils.EMPTY_OBJECT_ARRAY;
        }
 else         if (Object[].class.isAssignableFrom(arg.getClass())) {
          varArgs=(Object[])arg;
        }
      }
      if (varArgs == null) {
        varArgs=new Object[varArgsLen];
        System.arraycopy(arguments,fixedArgsLen,varArgs,0,varArgsLen);
      }
      args[actualLength - 1]=varArgs;
    }
    return args;
  }
  if (offset > 0) {
    Object[] args=new Object[actualLength];
    int length=actualLength - offset;
    if (length > 0) {
      System.arraycopy(arguments,0,args,offset,length);
    }
    return args;
  }
  return arguments;
}

Fixed version (ground truth):
/** 
 * 生成方法调用的实际参数
 */
public static Object[] getActualArguments(Object[] arguments,int actualLength,Class<?> varArgsClass,int offset){
  if (varArgsClass != null) {
    Object[] args=new Object[actualLength];
    int fixedArgsLen=actualLength - offset - 1;
    if (fixedArgsLen > 0) {
      System.arraycopy(arguments,0,args,offset,fixedArgsLen);
    }
    int varArgsLen=arguments.length - fixedArgsLen;
    if (varArgsLen == 0) {
      args[actualLength - 1]=Array.newInstance(varArgsClass,0);
    }
 else {
      Object varArgs=null;
      if (varArgsLen == 1) {
        Object arg=arguments[fixedArgsLen];
        if (arg == null) {
          varArgs=Array.newInstance(varArgsClass,0);
        }
 else         if (Object[].class.isAssignableFrom(arg.getClass())) {
          varArgs=arg;
        }
      }
      if (varArgs == null) {
        varArgs=Array.newInstance(varArgsClass,varArgsLen);
        System.arraycopy(arguments,fixedArgsLen,varArgs,0,varArgsLen);
      }
      args[actualLength - 1]=varArgs;
    }
    return args;
  }
  if (offset > 0) {
    Object[] args=new Object[actualLength];
    int length=actualLength - offset;
    if (length > 0) {
      System.arraycopy(arguments,0,args,offset,length);
    }
    return args;
  }
  return arguments;
}
Program: 56855
Project: 56855
Buggy source:
public ExtensionFunctionInvoker(MethodInfo method){
  this.method=method;
  this.length=method.getParameterCount();
  this.isVarArgs=method.isVarArgs();
}

Fixed version (ground truth):
public ExtensionFunctionInvoker(MethodInfo method){
  this.method=method;
  this.length=method.getParameterCount();
  if (method.isVarArgs()) {
    Class<?>[] types=method.getParameterTypes();
    this.varArgsClass=types[types.length - 1].getComponentType();
  }
 else {
    this.varArgsClass=null;
  }
}
Program: 56856
Project: 56856
Buggy source:
@Override public Object invoke(Object[] arguments){
  arguments=ParameterUtils.getActualArguments(arguments,length,isVarArgs,0);
  return method.invoke(null,arguments);
}

Fixed version (ground truth):
@Override public Object invoke(Object[] arguments){
  arguments=ParameterUtils.getActualArguments(arguments,length,varArgsClass,0);
  return method.invoke(null,arguments);
}
Program: 56857
Project: 56857
Buggy source:
public ClassBuildinMethodInvoker(MethodInfo method){
  this.method=method;
  this.length=method.getParameterCount();
  this.isVarArgs=method.isVarArgs();
}

Fixed version (ground truth):
public ClassBuildinMethodInvoker(MethodInfo method){
  this.method=method;
  this.length=method.getParameterCount();
  if (method.isVarArgs()) {
    Class<?>[] types=method.getParameterTypes();
    this.varArgsClass=types[types.length - 1].getComponentType();
  }
 else {
    this.varArgsClass=null;
  }
}
Program: 56858
Project: 56858
Buggy source:
@Override public Object invoke(Object object,Object[] arguments){
  arguments=ParameterUtils.getActualArguments(arguments,length,isVarArgs,0);
  return method.invoke(object,arguments);
}

Fixed version (ground truth):
@Override public Object invoke(Object object,Object[] arguments){
  arguments=ParameterUtils.getActualArguments(arguments,length,varArgsClass,0);
  return method.invoke(object,arguments);
}
Program: 56859
Project: 56859
Buggy source:
@Override public Object invoke(Object object,Object[] arguments){
  arguments=ParameterUtils.getActualArguments(arguments,length,isVarArgs,1);
  arguments[0]=object;
  return method.invoke(object,arguments);
}

Fixed version (ground truth):
@Override public Object invoke(Object object,Object[] arguments){
  arguments=ParameterUtils.getActualArguments(arguments,length,varArgsClass,1);
  arguments[0]=object;
  return method.invoke(null,arguments);
}
Program: 56860
Project: 56860
Buggy source:
public ExtensionMethodInvoker(MethodInfo method){
  this.method=method;
  this.length=method.getParameterCount();
  this.isVarArgs=method.isVarArgs();
}

Fixed version (ground truth):
public ExtensionMethodInvoker(MethodInfo method){
  this.method=method;
  this.length=method.getParameterCount();
  if (method.isVarArgs()) {
    Class<?>[] types=method.getParameterTypes();
    this.varArgsClass=types[types.length - 1].getComponentType();
  }
 else {
    this.varArgsClass=null;
  }
}
Program: 56861
Project: 56861
Buggy source:
public void invoke(JetTagContext ctx,Object[] arguments){
  arguments=ParameterUtils.getActualArguments(arguments,length,isVarArgs,1);
  arguments[0]=ctx;
  method.invoke(null,arguments);
}

Fixed version (ground truth):
public void invoke(JetTagContext ctx,Object[] arguments){
  arguments=ParameterUtils.getActualArguments(arguments,length,varArgsClass,1);
  arguments[0]=ctx;
  method.invoke(null,arguments);
}
Program: 56862
Project: 56862
Buggy source:
public TagInvoker(MethodInfo method){
  this.method=method;
  this.length=method.getParameterCount();
  this.isVarArgs=method.isVarArgs();
}

Fixed version (ground truth):
public TagInvoker(MethodInfo method){
  this.method=method;
  this.length=method.getParameterCount();
  if (method.isVarArgs()) {
    Class<?>[] types=method.getParameterTypes();
    this.varArgsClass=types[types.length - 1].getComponentType();
  }
 else {
    this.varArgsClass=null;
  }
}
Program: 56863
Project: 56863
Buggy source:
@Override public void initializeEngine(){
  engine.getGlobalResolver().registerMethods(StringUtils.class);
  engine.getGlobalResolver().registerMethods(String.class);
}

Fixed version (ground truth):
@Override public void initializeEngine(){
  engine.getGlobalResolver().registerMethods(StringUtils.class);
  engine.getGlobalResolver().registerMethods(StrUtils.class);
  engine.getGlobalResolver().registerMethods(String.class);
}
Program: 56864
Project: 56864
Buggy source:
private Object doInvoke(InterpretContext ctx,FunctionInvoker fn,Object[] arguments) throws InterpretException {
  boolean useLatest=(fn != null);
  if (fn == null) {
    Class<?>[] argumentTypes=ParameterUtils.getParameterTypes(arguments);
    fn=ctx.getGlobalResolver().resolveFunction(name,argumentTypes);
    if (fn == null) {
      String signature=SignatureUtils.getFunctionSignature(name,argumentTypes);
      throw new InterpretException(Errors.FUNCTION_NOT_FOUND,signature).set(position);
    }
    this.last=fn;
  }
  if (unsafe) {
    JetSecurityManager securityManager=ctx.getSecurityManager();
    if (securityManager != null) {
      try {
        fn.checkAccess(securityManager);
      }
 catch (      RuntimeException e) {
        throw new InterpretException(e).set(position);
      }
    }
    unsafe=false;
  }
  try {
    return fn.invoke(arguments);
  }
 catch (  InterpretException e) {
    throw e;
  }
catch (  RuntimeException e) {
    if (useLatest && Errors.isReflectIllegalArgument(e)) {
      return doInvoke(ctx,null,arguments);
    }
    throw new InterpretException(Errors.FUNCTION_INVOKE_ERROR).cause(e).set(position);
  }
}

Fixed version (ground truth):
private Object doInvoke(InterpretContext ctx,FunctionInvoker fn,Object[] arguments) throws InterpretException {
  boolean useLatest=(fn != null);
  if (fn == null) {
    Class<?>[] argumentTypes=ParameterUtils.getParameterTypes(arguments);
    fn=ctx.getGlobalResolver().resolveFunction(name,argumentTypes);
    if (fn == null) {
      String signature=SignatureUtils.getFunctionSignature(name,argumentTypes);
      throw new InterpretException(Errors.FUNCTION_NOT_FOUND,signature).set(position);
    }
    this.last=fn;
  }
  if (unsafe) {
    JetSecurityManager securityManager=ctx.getSecurityManager();
    if (securityManager != null) {
      try {
        fn.checkAccess(securityManager);
      }
 catch (      RuntimeException e) {
        throw new InterpretException(e).set(position);
      }
    }
    unsafe=false;
  }
  try {
    return fn.invoke(arguments);
  }
 catch (  InterpretException e) {
    throw e;
  }
catch (  RuntimeException e) {
    if (useLatest && Errors.isReflectIllegalArgument(e)) {
      return doInvoke(ctx,null,arguments);
    }
    throw new InterpretException(Errors.FUNCTION_INVOKE_ERROR,fn.getSignature()).cause(e).set(position);
  }
}
Program: 56865
Project: 56865
Buggy source:
@Override public void execute(InterpretContext ctx) throws InterpretException {
  JetWriter os=ctx.getWriter();
  if (encoder == null) {
    if (os.isStreaming()) {
      encoder=new ByteArrayEncoder(text,os.getCharset());
    }
 else {
      if (JdkUtils.IS_AT_LEAST_JAVA_7) {
        encoder=new Jdk7CharArrayEncoder(text);
      }
 else {
        encoder=new Jdk7CharArrayEncoder(text);
      }
    }
    text=null;
  }
  try {
    encoder.writeTo(os);
  }
 catch (  IOException e) {
    throw new IllegalStateException(e);
  }
}

Fixed version (ground truth):
@Override public void execute(InterpretContext ctx) throws InterpretException {
  JetWriter os=ctx.getWriter();
  if (encoder == null) {
    if (os.isStreaming()) {
      encoder=new ByteArrayEncoder(text,os.getCharset());
    }
 else {
      if (JdkUtils.IS_AT_LEAST_JAVA_7) {
        encoder=new Jdk7CharArrayEncoder(text);
      }
 else {
        encoder=new Jdk6CharArrayEncoder(text);
      }
    }
    text=null;
  }
  try {
    encoder.writeTo(os);
  }
 catch (  IOException e) {
    throw new IllegalStateException(e);
  }
}