nus-yam/ex-repair huggingface dataset:
Program: 87335
Project: 87335
Buggy source:
/** 
 * Return a new ListPattern forming the parts of this pattern without  the matching elements of the given pattern. 
 */
public ListPattern remove(ListPattern pattern){
  ListPattern result=new ListPattern(_modality);
  int i=0;
  boolean takingItems=false;
  while (i < size()) {
    if (takingItems) {
      result.add(getItem(i));
    }
 else     if (i < pattern.size() && pattern.getItem(i).equals(getItem(i))) {
      ;
    }
 else {
      takingItems=true;
      result.add(getItem(i));
    }
    i+=1;
  }
  if (isFinished() && !(result.isEmpty() && pattern.isFinished())) {
    result.setFinished();
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Return a new ListPattern forming the parts of this pattern without  the matching elements of the given pattern. 
 */
public ListPattern remove(ListPattern pattern){
  ListPattern result=new ListPattern(_modality);
  int i=0;
  boolean takingItems=false;
  while (i < size()) {
    if (takingItems) {
      result.add(getItem(i));
    }
 else     if (i < pattern.size() && pattern.getItem(i).equalPrimitive(getItem(i))) {
      ;
    }
 else {
      takingItems=true;
      result.add(getItem(i));
    }
    i+=1;
  }
  if (isFinished() && !(result.isEmpty() && pattern.isFinished())) {
    result.setFinished();
  }
  return result;
}
Program: 87336
Project: 87336
Buggy source:
/** 
 * Two patterns are equal if they contain the same items.
 */
public boolean equals(ListPattern pattern){
  if (_modality != pattern._modality)   return false;
  if (size() != pattern.size())   return false;
  for (int i=0, n=size(); i < n; ++i) {
    if (!pattern.getItem(i).equals(getItem(i))) {
      return false;
    }
  }
  return _finished == pattern.isFinished();
}

Fixed version (ground truth):
/** 
 * Two patterns are equal if they contain the same items.
 */
public boolean equals(ListPattern pattern){
  if (_modality != pattern._modality)   return false;
  if (size() != pattern.size())   return false;
  for (int i=0, n=size(); i < n; ++i) {
    if (!pattern.getItem(i).equalPrimitive(getItem(i))) {
      return false;
    }
  }
  return _finished == pattern.isFinished();
}
Program: 87337
Project: 87337
Buggy source:
/** 
 * Construct a copy of this pattern, so that it can be modified  without affecting the original.
 */
public ListPattern clone(){
  ListPattern result=new ListPattern(_modality);
  for (  Pattern pattern : _list) {
    result.add(pattern);
  }
  if (isFinished()) {
    result.setFinished();
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Construct a copy of this pattern, so that it can be modified  without affecting the original.
 */
public ListPattern clone(){
  ListPattern result=new ListPattern(_modality);
  for (  PrimitivePattern pattern : _list) {
    result.add(pattern);
  }
  if (isFinished()) {
    result.setFinished();
  }
  return result;
}
Program: 87338
Project: 87338
Buggy source:
/** 
 * Render the list pattern as a string.
 */
public String toString(){
  String result="String_Node_Str";
  for (  Pattern pattern : _list) {
    result+=pattern.toString() + "String_Node_Str";
  }
  if (_finished)   result+="String_Node_Str";
  return result + "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Render the list pattern as a string.
 */
public String toString(){
  String result="String_Node_Str";
  for (  PrimitivePattern pattern : _list) {
    result+=pattern.toString() + "String_Node_Str";
  }
  if (_finished)   result+="String_Node_Str";
  return result + "String_Node_Str";
}
Program: 87340
Project: 87340
Buggy source:
/** 
 * Return a new ListPattern formed from the contents of this list pattern and  the given PrimitivePattern appended to it.
 */
public ListPattern append(PrimitivePattern pattern){
  ListPattern result=new ListPattern(_modality);
  for (  Pattern item : _list) {
    result.add(item);
  }
  result.add(pattern);
  return result;
}

Fixed version (ground truth):
/** 
 * Return a new ListPattern formed from the contents of this list pattern and  the given PrimitivePattern appended to it.
 */
public ListPattern append(PrimitivePattern pattern){
  ListPattern result=new ListPattern(_modality);
  for (  PrimitivePattern item : _list) {
    result.add(item);
  }
  result.add(pattern);
  return result;
}
Program: 87341
Project: 87341
Buggy source:
@Test public void simpleLearning1(){
  _model1.recogniseAndLearn(_list1);
  assertEquals(1,_model1.getLtmByModality(_list1).getChildren().size());
  Link firstChild=_model1.getLtmByModality(_list1).getChildren().get(0);
  assertFalse(_emptyList.equals(firstChild.getChildNode().getContents()));
  assertTrue(firstChild.getTest().equals(_prim1Test));
  assertTrue(firstChild.getChildNode().getContents().equals(_prim1Test));
  assertTrue(firstChild.getChildNode().getImage().equals(_prim1));
}

Fixed version (ground truth):
public void simpleLearning1(ListPattern list,ListPattern emptyList,ListPattern prim,ListPattern primTest){
  _model1.recogniseAndLearn(list);
  assertEquals(1,_model1.getLtmByModality(list).getChildren().size());
  Link firstChild=_model1.getLtmByModality(list).getChildren().get(0);
  assertFalse(emptyList.equals(firstChild.getChildNode().getContents()));
  assertTrue(firstChild.getTest().equals(primTest));
  assertTrue(firstChild.getChildNode().getContents().equals(primTest));
  assertTrue(firstChild.getChildNode().getImage().equals(prim));
}
Program: 87342
Project: 87342
Buggy source:
@Before public void setupModels(){
  _model1=new Chrest();
  _model2=new Chrest();
  _list1=Pattern.makeVisualList(new int[]{1,2,3,4});
  _list1.setFinished();
  _list2=Pattern.makeVisualList(new int[]{3,4});
  _list2.setFinished();
  _list3=Pattern.makeVisualList(new int[]{1,2});
  _list3.setFinished();
  _list3Test=_list3.clone();
  _list3Test.setNotFinished();
  _list4=Pattern.makeVisualList(new int[]{1});
  _prim1=Pattern.makeVisualList(new int[]{1});
  _prim1.setFinished();
  _prim1Test=_prim1.clone();
  _prim1Test.setNotFinished();
  _prim2=Pattern.makeVisualList(new int[]{2});
  _prim2.setFinished();
  _emptyList=Pattern.makeVisualList(new int[]{});
}

Fixed version (ground truth):
@Before public void setupModels(){
  _model1=new Chrest();
  _model2=new Chrest();
  _list1=Pattern.makeVisualList(new int[]{1,2,3,4});
  _list1.setFinished();
  _list2=Pattern.makeVisualList(new int[]{3,4});
  _list2.setFinished();
  _list3=Pattern.makeVisualList(new int[]{1,2});
  _list3.setFinished();
  _list3Test=_list3.clone();
  _list3Test.setNotFinished();
  _list4=Pattern.makeVisualList(new int[]{1});
  _prim1=Pattern.makeVisualList(new int[]{1});
  _prim1.setFinished();
  _prim1Test=_prim1.clone();
  _prim1Test.setNotFinished();
  _prim2=Pattern.makeVisualList(new int[]{2});
  _prim2.setFinished();
  _emptyList=Pattern.makeVisualList(new int[]{});
  _iosList1=new ListPattern();
  _iosList1.add(new ItemSquarePattern("String_Node_Str",1,2));
  _iosList1.add(new ItemSquarePattern("String_Node_Str",2,2));
  _iosList1.add(new ItemSquarePattern("String_Node_Str",3,2));
  _iosList1.add(new ItemSquarePattern("String_Node_Str",4,2));
  _emptyIosList=new ListPattern();
  _iosPrim1=new ListPattern();
  _iosPrim1.add(new ItemSquarePattern("String_Node_Str",1,2));
  _iosPrim1.setFinished();
  _iosPrim1Test=_iosPrim1.clone();
  _iosPrim1Test.setNotFinished();
}
Program: 87343
Project: 87343
Buggy source:
@Test public void testListPatternEquality(){
  assertFalse(Pattern.makeVisualList(new int[]{}).equals(Pattern.makeVerbalList(new int[]{})));
  assertTrue(_list1.equals(Pattern.makeVisualList(new int[]{1,2,3,4})));
  assertFalse(_list1.equals(Pattern.makeVisualList(new int[]{1,2,3})));
  assertFalse(_list1.equals(Pattern.makeVisualList(new int[]{1,2,3,4,5})));
  assertFalse(_list1.equals(Pattern.makeVisualList(new int[]{1,2,4,5})));
  assertFalse(_list1.equals(_list2));
  ListPattern list1Copy=Pattern.makeVisualList(new int[]{1,2,3,4});
  list1Copy.setFinished();
  assertFalse(_list1.equals(list1Copy));
  _list1.setFinished();
  assertTrue(_list1.equals(list1Copy));
}

Fixed version (ground truth):
@Test public void testListPatternEquality(){
  assertFalse(Pattern.makeVisualList(new int[]{}).equals(Pattern.makeVerbalList(new int[]{})));
  assertTrue(_list1.equals(Pattern.makeVisualList(new int[]{1,2,3,4})));
  assertFalse(_list1.equals(Pattern.makeVisualList(new int[]{1,2,3})));
  assertFalse(_list1.equals(Pattern.makeVisualList(new int[]{1,2,3,4,5})));
  assertFalse(_list1.equals(Pattern.makeVisualList(new int[]{1,2,4,5})));
  assertFalse(_list1.equals(_list2));
  ListPattern list1Copy=Pattern.makeVisualList(new int[]{1,2,3,4});
  list1Copy.setFinished();
  assertFalse(_list1.equals(list1Copy));
  _list1.setFinished();
  assertTrue(_list1.equals(list1Copy));
  ListPattern iosList1=new ListPattern();
  iosList1.add(_ios1);
  ListPattern iosList2=new ListPattern();
  iosList2.add(_ios2);
  ListPattern iosList3=new ListPattern();
  iosList3.add(_ios1a);
  assertTrue(iosList1.equals(iosList3));
  assertFalse(iosList1.equals(iosList2));
}
Program: 87344
Project: 87344
Buggy source:
@Test public void testNumberMatches(){
  assertTrue(_number1.equals(NumberPattern.create(1)));
  assertFalse(_number1.equals(_number2));
  assertTrue(_number1.matches(NumberPattern.create(1)));
  assertFalse(_number1.matches(_number2));
}

Fixed version (ground truth):
@Test public void testNumberMatches(){
  assertTrue(_number1.equalPrimitive(NumberPattern.create(1)));
  assertFalse(_number1.equalPrimitive(_number2));
  assertTrue(_number1.matches(NumberPattern.create(1)));
  assertFalse(_number1.matches(_number2));
}
Program: 87345
Project: 87345
Buggy source:
@Before public void setupExamples(){
  _number1=Pattern.makeNumber(1);
  _number2=Pattern.makeNumber(2);
  _string1=Pattern.makeString("String_Node_Str");
  _string2=Pattern.makeString("String_Node_Str");
  _list1=Pattern.makeVisualList(new int[]{1,2,3,4});
  _list2=Pattern.makeVisualList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  _list3=Pattern.makeVisualList(new int[]{1,2,3});
}

Fixed version (ground truth):
@Before public void setupExamples(){
  _number1=Pattern.makeNumber(1);
  _number2=Pattern.makeNumber(2);
  _string1=Pattern.makeString("String_Node_Str");
  _string2=Pattern.makeString("String_Node_Str");
  _ios1=new ItemSquarePattern("String_Node_Str",2,3);
  _ios1a=new ItemSquarePattern("String_Node_Str",2,3);
  _ios2=new ItemSquarePattern("String_Node_Str",2,3);
  _list1=Pattern.makeVisualList(new int[]{1,2,3,4});
  _list2=Pattern.makeVisualList(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
  _list3=Pattern.makeVisualList(new int[]{1,2,3});
}
Program: 87346
Project: 87346
Buggy source:
@Test public void testStringMatches(){
  assertTrue(_string1.equals(StringPattern.create("String_Node_Str")));
  assertFalse(_string1.equals(_string2));
  assertTrue(_string1.matches(StringPattern.create("String_Node_Str")));
  assertFalse(_string1.matches(_string2));
}

Fixed version (ground truth):
@Test public void testStringMatches(){
  assertTrue(_string1.equalPrimitive(StringPattern.create("String_Node_Str")));
  assertFalse(_string1.equalPrimitive(_string2));
  assertTrue(_string1.matches(StringPattern.create("String_Node_Str")));
  assertFalse(_string1.matches(_string2));
}
Program: 87349
Project: 87349
Buggy source:
/** 
 * Called to Extract errors from a Bobik response and pass them on to user's listener
 * @param bobikResponse
 * @param listener
 * @throws BobikException not common, thrown on surprise parse errors
 */
protected void processErrors(JSONObject bobikResponse,JobListener listener) throws JSONException {
  JSONArray errors;
  try {
    errors=bobikResponse.getJSONArray(BobikConstants.ERROR_TOKEN_LABEL);
  }
 catch (  JSONException e) {
    return;
  }
  if (errors != null && errors.length() > 0) {
    Collection<String> messages=new ArrayList<String>(errors.length());
    for (int i=0; i < errors.length(); i++)     messages.add(errors.getString(i));
    listener.onErrors(messages);
  }
}

Fixed version (ground truth):
/** 
 * Called to extract errors from a Bobik response and pass them on to user's listener
 * @param bobikResponse
 * @param listener
 * @throws BobikException not common, thrown on surprise parse errors
 */
protected void processErrors(JSONObject bobikResponse,JobListener listener) throws JSONException {
  try {
    JSONArray errors=bobikResponse.getJSONArray(BobikConstants.ERROR_TOKEN_LABEL);
    if (errors != null && errors.length() > 0) {
      Collection<String> messages=new ArrayList<String>(errors.length());
      for (int i=0; i < errors.length(); i++)       messages.add(errors.getString(i));
      listener.onErrors(messages);
    }
  }
 catch (  JSONException e) {
    return;
  }
}
Program: 87350
Project: 87350
Buggy source:
/** 
 * Returns true if the failure represents one where a retry should occur.
 * @param failure the exception to examine if retry is necessary.
 * @return true if retry is necessary.
 */
public static boolean isRetryException(final Throwable failure){
  return isServerUnavailable(failure) || isUnableToLockRow(failure);
}

Fixed version (ground truth):
/** 
 * Returns true if the failure represents one where a retry should occur.
 * @param failure the exception to examine if retry is necessary.
 * @return true if retry is necessary.
 */
public static boolean isRetryException(final Throwable failure){
  return isServerUnavailable(failure) || isUnableToLockRow(failure) || isServiceUnavailable(failure);
}
Program: 87351
Project: 87351
Buggy source:
/** 
 * This constructor sets the sessionMgr to use, the type of web service and the class of the web service being used.
 * @param sessionMgr     manages our sessions with SFDC.
 * @param webServiceType the type of web service being used.
 * @throws IllegalArgumentException if sessionMgr, webServiceType or serviceClass are null.
 */
public SalesforceWebServicePortInvoker(final SessionMgr sessionMgr,final WebServiceTypeEnum webServiceType){
  this.sessionMgr=IntegrityUtil.ensure(sessionMgr,"String_Node_Str");
  this.webServiceType=IntegrityUtil.ensure(webServiceType,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * This constructor sets the sessionMgr to use, the type of web service and the class of the web service being used.
 * @param < P >
 * @param sessionMgr     manages our sessions with SFDC.
 * @param webServiceType the type of web service being used.
 * @throws IllegalArgumentException if sessionMgr, webServiceType or serviceClass are null.
 */
public <P>SalesforceWebServicePortInvoker(final WebService<P> service,final SessionMgr sessionMgr,final WebServiceTypeEnum webServiceType){
  this.sessionMgr=IntegrityUtil.ensure(sessionMgr,"String_Node_Str");
  this.webServiceType=IntegrityUtil.ensure(webServiceType,"String_Node_Str");
  this.port=new AtomicReference(SalesforceWebServiceUtil.createPort(sessionMgr.getSession(),webServiceType,service));
}
Program: 87352
Project: 87352
Buggy source:
/** 
 * When an exception happens on call, this method will handle the exception.
 * @param callFailure the exception that arose when calling SFDC.
 * @param method      the method being called when the failure arose.
 * @param session     the session being used when calling SFDC.
 * @throws Throwable if the exception cannot be handled.
 */
protected void handleException(final Throwable callFailure,final Method method,final Session session) throws Throwable {
  if (ExceptionUtil.isReloginException(callFailure)) {
    getLogger().log(Level.INFO,"String_Node_Str",method.getName());
    getSessionMgr().resetSession(session);
  }
 else   if (ExceptionUtil.isRetryException(callFailure)) {
    getLogger().log(Level.WARNING,"String_Node_Str",new Object[]{method.getName(),callFailure.getLocalizedMessage()});
    pause(new byte[0]);
  }
 else {
    getLogger().log(Level.FINE,"String_Node_Str",new Object[]{method.getName(),callFailure.getLocalizedMessage()});
    throw callFailure;
  }
}

Fixed version (ground truth):
/** 
 * When an exception happens on call, this method will handle the exception.
 * @param callFailure the exception that arose when calling SFDC.
 * @param method      the method being called when the failure arose.
 * @param session     the session being used when calling SFDC.
 * @throws Throwable if the exception cannot be handled.
 */
protected void handleException(final Throwable callFailure,final WebService webService,final Object proxy,final Method method,final Session session,final int totalCalls) throws Throwable {
  if (ExceptionUtil.isReloginException(callFailure)) {
    getLogger().log(Level.INFO,"String_Node_Str",new Object[]{method.getName(),totalCalls});
    getSessionMgr().resetSession(session);
    port.set(SalesforceWebServiceUtil.createPort(session,getWebServiceType(),webService));
  }
 else   if (ExceptionUtil.isRetryException(callFailure)) {
    getLogger().log(Level.WARNING,"String_Node_Str",new Object[]{method.getName(),totalCalls});
    pause(new byte[0],totalCalls);
  }
 else {
    getLogger().log(Level.FINE,"String_Node_Str" + method.getName() + "String_Node_Str",callFailure);
    throw callFailure;
  }
}
Program: 87353
Project: 87353
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public Object invoke(final WebService webService,final Object proxy,final Method method,final Object[] args) throws Throwable {
  int totalCalls=0;
  getLogger().log(Level.FINE,"String_Node_Str",method.getName());
  Session session=null;
  while (isCallable(totalCalls++)) {
    try {
      session=getSessionMgr().getSession();
      return method.invoke(SalesforceWebServiceUtil.createPort(session,getWebServiceType(),webService),args);
    }
 catch (    final Exception callFailure) {
      handleException(callFailure,method,session);
    }
  }
  throw new IllegalStateException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public Object invoke(final WebService webService,final Object proxy,final Method method,final Object[] args) throws Throwable {
  int totalCalls=0;
  getLogger().log(Level.FINE,"String_Node_Str",method.getName());
  Session session=null;
  while (isCallable(totalCalls++)) {
    try {
      session=getSessionMgr().getSession();
      final Object retVal=method.invoke(port.get(),args);
      return retVal;
    }
 catch (    final Exception callFailure) {
      handleException(callFailure,webService,proxy,method,session,totalCalls);
    }
  }
  throw new IllegalStateException("String_Node_Str");
}
Program: 87354
Project: 87354
Buggy source:
/** 
 * Pauses execution.
 */
void pause(final Object lock){
  try {
    getLogger().log(Level.INFO,"String_Node_Str");
synchronized (lock) {
      lock.wait(DEFAULT_PAUSE_TIME);
    }
  }
 catch (  final InterruptedException ex) {
    getLogger().log(Level.WARNING,"String_Node_Str",ex);
  }
}

Fixed version (ground truth):
/** 
 * Pauses execution.
 */
void pause(final Object lock,final int totalCalls){
  try {
    final long waitTime=RANDOM_PAUSE.nextInt(DEFAULT_PAUSE_TIME);
    getLogger().log(Level.INFO,"String_Node_Str",new Object[]{waitTime,totalCalls});
synchronized (lock) {
      lock.wait(waitTime);
    }
  }
 catch (  final InterruptedException ex) {
    getLogger().log(Level.WARNING,"String_Node_Str",ex);
  }
}
Program: 87355
Project: 87355
Buggy source:
/** 
 * Create a port usind data from the sessionMgr.
 * @param < P >            the type of web service endpoint.
 * @param sessionMgr     contains a session which contains a loginResult, containing a session id to use for SFDC.
 * @param webServiceType the type of web service.
 * @param service        the web service.
 * @return a usable port.
 */
public static <P>P createPort(final SessionMgr sessionMgr,final WebServiceTypeEnum webServiceType,final WebService<P> service){
  return createPort(sessionMgr.getSession(),webServiceType,service);
}

Fixed version (ground truth):
/** 
 * Create a port usind data from the sessionMgr.
 * @param < P >            the type of web service endpoint.
 * @param sessionMgr     contains a session which contains a loginResult, containing a session id to use for SFDC.
 * @param webServiceType the type of web service.
 * @param service        the web service.
 * @return a usable port.
 */
public static <P>P createPort(final SessionMgr sessionMgr,final WebServiceTypeEnum webServiceType,final WebService<P> service){
  service.getPort();
  return createPort(sessionMgr.getSession(),webServiceType,service);
}
Program: 87356
Project: 87356
Buggy source:
/** 
 * Create a proxied port. This manages auto login and retries when calling SFDC.
 * @param < P >            the type of web service endpoint.
 * @param sessionMgr     will be used to create sessions for SFDC calls.
 * @param webServiceType the type of web service being used.
 * @param service        the web service.
 * @return a usable port.
 */
public static <P>P createProxyPort(final SessionMgr sessionMgr,final WebServiceTypeEnum webServiceType,final WebService<P> service){
  return new WebServiceInvocationDecorator<>(service,new SalesforceWebServicePortInvoker(sessionMgr,webServiceType)).getPort();
}

Fixed version (ground truth):
/** 
 * Create a proxied port. This manages auto login and retries when calling SFDC.
 * @param < P >            the type of web service endpoint.
 * @param sessionMgr     will be used to create sessions for SFDC calls.
 * @param webServiceType the type of web service being used.
 * @param service        the web service.
 * @return a usable port.
 */
public static <P>P createProxyPort(final SessionMgr sessionMgr,final WebServiceTypeEnum webServiceType,final WebService<P> service){
  service.getPort();
  return new WebServiceInvocationDecorator<>(service,new SalesforceWebServicePortInvoker(service,sessionMgr,webServiceType)).getPort();
}
Program: 87358
Project: 87358
Buggy source:
/** 
 * Guesses the   {@link Format}based on the literal index provided for this element.
 * @return the type
 */
private Format guessFormat(Element element){
  String literalIndex=getLiteralIndex(element);
  if (literalIndex != null) {
    literalIndex=TextUtils.stripTags(literalIndex.trim(),false);
    if (literalIndex.toLowerCase().startsWith(getType(element))) {
      return Format.ELEMENT;
    }
    if (literalIndex.startsWith("String_Node_Str"))     return Format.DOUBLE_BRACKET;
    if (literalIndex.endsWith("String_Node_Str"))     return Format.POINT;
    if (literalIndex.endsWith("String_Node_Str"))     return Format.BRACKET;
  }
  return Format.NONE;
}

Fixed version (ground truth):
/** 
 * Guesses the   {@link Format}based on the literal index provided for this element.
 * @return the type
 */
private Format guessFormat(Element element){
  String literalIndex=getLiteralIndex(element);
  if (literalIndex != null) {
    literalIndex=TextUtils.stripTags(literalIndex.trim(),false);
    final String type=getType(element);
    if (type != null && literalIndex.toLowerCase().startsWith(type)) {
      return Format.ELEMENT;
    }
    if (literalIndex.startsWith("String_Node_Str"))     return Format.DOUBLE_BRACKET;
    if (literalIndex.endsWith("String_Node_Str"))     return Format.POINT;
    if (literalIndex.endsWith("String_Node_Str"))     return Format.BRACKET;
  }
  return Format.NONE;
}
Program: 87359
Project: 87359
Buggy source:
@Override public void setOrigin(OverlayWidgetOrigin origin){
  this.origin=origin;
  if (overlayStrategy != null) {
    overlayStrategy.setOrigin(getOverlayElement(),origin.name());
  }
}

Fixed version (ground truth):
@Override public void setOrigin(OverlayWidgetOrigin origin){
  this.origin=origin;
  if (overlayStrategy != null) {
    overlayStrategy.setOrigin(getElement(),origin.name());
  }
}
Program: 87360
Project: 87360
Buggy source:
/** 
 * Similar   {@link #select(String,org.nsesa.editor.gwt.core.client.ui.overlay.document.OverlayWidget)}, but using recursion.
 * @param split an array of expression parts
 * @param root  the root node
 * @param found a list of {@link OverlayWidget}s to store the matching nodes in
 */
public void select(final String[] split,final OverlayWidget root,final List<OverlayWidget> found){
  if (split != null && split.length > 0) {
    final String expression=split[0];
    for (    final Matcher matcher : MATCHERS) {
      if (matcher.applicable(expression)) {
        if (matcher.matches(expression,root)) {
          if (split.length == 1) {
            found.add(root);
          }
          for (          final OverlayWidget child : root.getChildOverlayWidgets()) {
            final List<String> copy=Arrays.asList(split).subList(1,split.length);
            final String[] tail=copy.toArray(new String[copy.size()]);
            select(tail,child,found);
          }
          break;
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Similar   {@link #select(String,org.nsesa.editor.gwt.core.client.ui.overlay.document.OverlayWidget)}, but using recursion.
 * @param split         an array of expression parts
 * @param overlayWidget the root node
 * @param found         a list of {@link OverlayWidget}s to store the matching nodes in
 */
public void select(final String[] split,final OverlayWidget overlayWidget,final List<OverlayWidget> found){
  if (split != null && split.length > 0) {
    final String expression=split[0];
    for (    final Matcher matcher : MATCHERS) {
      if (matcher.applicable(expression)) {
        if (matcher.matches(expression,overlayWidget)) {
          if (split.length == 1) {
            found.add(overlayWidget);
          }
 else {
            for (            final OverlayWidget child : overlayWidget.getChildOverlayWidgets()) {
              final List<String> copy=Arrays.asList(split).subList(1,split.length);
              final String[] tail=copy.toArray(new String[copy.size()]);
              select(tail,child,found);
            }
          }
          break;
        }
      }
    }
  }
}
Program: 87361
Project: 87361
Buggy source:
public void retrieveRevisions(){
  comparisonProvider.getRevisions(new AsyncCallback<List<RevisionDTO>>(){
    @Override public void onFailure(    Throwable caught){
      clientFactory.getEventBus().fireEvent(new CriticalErrorEvent("String_Node_Str",caught));
    }
    @Override public void onSuccess(    List<RevisionDTO> result){
      view.setAvailableRevisions(result);
      if (result.size() > 1) {
        retrieveRevisionContent(result.get(1).getRevisionID(),result.get(0).getRevisionID());
      }
 else {
        retrieveRevisionContent(result.get(0).getRevisionID(),result.get(0).getRevisionID());
      }
    }
  }
);
}

Fixed version (ground truth):
public void retrieveRevisions(){
  revisionA=null;
  revisionB=null;
  comparisonProvider.getRevisions(new AsyncCallback<List<RevisionDTO>>(){
    @Override public void onFailure(    Throwable caught){
      clientFactory.getEventBus().fireEvent(new CriticalErrorEvent("String_Node_Str",caught));
    }
    @Override public void onSuccess(    List<RevisionDTO> result){
      view.setAvailableRevisions(result);
      if (result.size() > 1) {
        retrieveRevisionContent(result.get(1).getRevisionID(),result.get(0).getRevisionID());
      }
 else {
        retrieveRevisionContent(result.get(0).getRevisionID(),result.get(0).getRevisionID());
      }
    }
  }
);
}
Program: 87362
Project: 87362
Buggy source:
/** 
 * Registers the listeners for events that are being fired by the deadline tracker.
 */
private void registerListeners(){
  deadlinePassedEventHandlerRegistration=documentEventBus.addHandler(DeadlinePassedEvent.TYPE,new DeadlinePassedEventHandler(){
    @Override public void onEvent(    DeadlinePassedEvent event){
      if (event.getDocumentController() == documentController) {
        view.setPastStyle();
        view.setDeadline(getFormattedDeadline());
      }
    }
  }
);
  hour24DeadlineEventHandlerRegistration=documentEventBus.addHandler(Deadline24HourEvent.TYPE,new Deadline24HourEventHandler(){
    @Override public void onEvent(    Deadline24HourEvent event){
      if (event.getDocumentController() == documentController) {
        view.set24HourStyle();
        view.setDeadline(getFormattedDeadline());
      }
    }
  }
);
  hour1DeadlineEventHandlerRegistration=documentEventBus.addHandler(Deadline1HourEvent.TYPE,new Deadline1HourEventHandler(){
    @Override public void onEvent(    Deadline1HourEvent event){
      if (event.getDocumentController() == documentController) {
        view.set1HourStyle();
        view.setDeadline(getFormattedDeadline());
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Registers the listeners for events that are being fired by the deadline tracker.
 */
private void registerListeners(){
  deadlinePassedEventHandlerRegistration=documentEventBus.addHandler(DeadlinePassedEvent.TYPE,new DeadlinePassedEventHandler(){
    @Override public void onEvent(    DeadlinePassedEvent event){
      if (event.getDocumentController() == documentController) {
        view.setPastStyle();
        view.setDeadline(getFormattedDeadlineMessage());
      }
    }
  }
);
  hour24DeadlineEventHandlerRegistration=documentEventBus.addHandler(Deadline24HourEvent.TYPE,new Deadline24HourEventHandler(){
    @Override public void onEvent(    Deadline24HourEvent event){
      if (event.getDocumentController() == documentController) {
        view.set24HourStyle();
        view.setDeadline(getFormattedDeadlineMessage());
      }
    }
  }
);
  hour1DeadlineEventHandlerRegistration=documentEventBus.addHandler(Deadline1HourEvent.TYPE,new Deadline1HourEventHandler(){
    @Override public void onEvent(    Deadline1HourEvent event){
      if (event.getDocumentController() == documentController) {
        view.set1HourStyle();
        view.setDeadline(getFormattedDeadlineMessage());
      }
    }
  }
);
}
Program: 87363
Project: 87363
Buggy source:
@Override public void onEvent(Deadline1HourEvent event){
  if (event.getDocumentController() == documentController) {
    view.set1HourStyle();
    view.setDeadline(getFormattedDeadline());
  }
}

Fixed version (ground truth):
@Override public void onEvent(Deadline1HourEvent event){
  if (event.getDocumentController() == documentController) {
    view.set1HourStyle();
    view.setDeadline(getFormattedDeadlineMessage());
  }
}
Program: 87366
Project: 87366
Buggy source:
/** 
 * Creates a simple   {@link AmendmentController} associated with a given <tt>amendmentContainerDTO</tt>
 * @param amendmentContainerDTO the amendment container DTO to create a controller for
 * @return the controller
 */
private AmendmentController createAmendmentController(final AmendmentContainerDTO amendmentContainerDTO){
  final AmendmentController amendmentController=documentController.getInjector().getAmendmentController();
  amendmentController.registerListeners();
  amendmentController.registerViews();
  amendmentController.setModel(amendmentContainerDTO);
  amendmentController.setDocumentController(documentController);
  return amendmentController;
}

Fixed version (ground truth):
/** 
 * Creates a simple   {@link AmendmentController} associated with a given <tt>amendmentContainerDTO</tt>
 * @param amendmentContainerDTO the amendment container DTO to create a controller for
 * @return the controller
 */
private AmendmentController createAmendmentController(final AmendmentContainerDTO amendmentContainerDTO){
  final AmendmentController amendmentController=documentController.getInjector().getAmendmentController();
  amendmentController.registerViews();
  amendmentController.registerListeners();
  amendmentController.setModel(amendmentContainerDTO);
  amendmentController.setDocumentController(documentController);
  return amendmentController;
}
Program: 87368
Project: 87368
Buggy source:
/** 
 * Get the injection point expression for a given <tt>overlayWidget</tt>. This expression uniquely identifies the position within its own branch up to the root.
 * @param reference the overlay widget to find the position expression for
 * @return the injection point expression (xpath like).
 */
@Override public AmendableWidgetReference getInjectionPoint(final OverlayWidget parent,final OverlayWidget reference,final OverlayWidget overlayWidget){
  AmendableWidgetReference injectionPoint;
  final String xPath=findXPathExpressionToOverlayWidget(reference);
  if (overlayWidget != null) {
    final boolean sibling=parent != reference;
    final int injectionPosition=overlayWidgetInjectionStrategy.getInjectionPosition(sibling ? reference.getParentOverlayWidget() : reference,reference,overlayWidget);
    injectionPoint=new AmendableWidgetReference(true,sibling,xPath,overlayWidget.getNamespaceURI(),overlayWidget.getType(),sibling ? (injectionPosition - reference.getParentOverlayWidget().getChildOverlayWidgets().indexOf(reference)) : injectionPosition);
  }
 else {
    injectionPoint=new AmendableWidgetReference(false,false,xPath,reference.getNamespaceURI(),reference.getType(),-1);
  }
  injectionPoint.setReferenceID(UUID.uuid());
  LOG.info("String_Node_Str" + injectionPoint);
  return injectionPoint;
}

Fixed version (ground truth):
/** 
 * Get the injection point expression for a given <tt>overlayWidget</tt>. This expression uniquely identifies the position within its own branch up to the root.
 * @param reference the overlay widget to find the position expression for
 * @return the injection point expression (xpath like).
 */
@Override public AmendableWidgetReference getInjectionPoint(final OverlayWidget parent,final OverlayWidget reference,final OverlayWidget overlayWidget){
  AmendableWidgetReference injectionPoint;
  final String xPath=findXPathExpressionToOverlayWidget(reference);
  if (overlayWidget.isIntroducedByAnAmendment()) {
    final boolean sibling=parent != reference;
    final int injectionPosition=overlayWidgetInjectionStrategy.getInjectionPosition(sibling ? reference.getParentOverlayWidget() : reference,reference,overlayWidget);
    injectionPoint=new AmendableWidgetReference(true,sibling,xPath,overlayWidget.getNamespaceURI(),overlayWidget.getType(),sibling ? (injectionPosition - reference.getParentOverlayWidget().getChildOverlayWidgets().indexOf(reference)) : injectionPosition);
  }
 else {
    injectionPoint=new AmendableWidgetReference(false,false,xPath,reference.getNamespaceURI(),reference.getType(),-1);
  }
  injectionPoint.setReferenceID(UUID.uuid());
  LOG.info("String_Node_Str" + injectionPoint);
  return injectionPoint;
}
Program: 87369
Project: 87369
Buggy source:
/** 
 * Get the injection point expression for a given <tt>overlayWidget</tt>. This expression uniquely identifies the position within its own branch up to the root.
 * @param reference the overlay widget to find the position expression for
 * @return the injection point expression (xpath like).
 */
@Override public AmendableWidgetReference getInjectionPoint(final OverlayWidget parent,final OverlayWidget reference,final OverlayWidget child){
  AmendableWidgetReference injectionPoint;
  final String xPath=findXPathExpressionToOverlayWidget(reference);
  if (child != null) {
    final boolean sibling=parent != reference;
    injectionPoint=new AmendableWidgetReference(true,sibling,xPath,child.getNamespaceURI(),child.getType(),overlayWidgetInjectionStrategy.getInjectionPosition(sibling ? reference.getParentOverlayWidget() : reference,reference,child));
  }
 else {
    injectionPoint=new AmendableWidgetReference(false,false,xPath,reference.getNamespaceURI(),reference.getType(),-1);
  }
  injectionPoint.setReferenceID(UUID.uuid());
  return injectionPoint;
}

Fixed version (ground truth):
/** 
 * Get the injection point expression for a given <tt>overlayWidget</tt>. This expression uniquely identifies the position within its own branch up to the root.
 * @param reference the overlay widget to find the position expression for
 * @return the injection point expression (xpath like).
 */
@Override public AmendableWidgetReference getInjectionPoint(final OverlayWidget parent,final OverlayWidget reference,final OverlayWidget child){
  AmendableWidgetReference injectionPoint;
  final String xPath=findXPathExpressionToOverlayWidget(reference);
  if (child != null) {
    final boolean sibling=parent != reference;
    final int injectionPosition=overlayWidgetInjectionStrategy.getInjectionPosition(sibling ? reference.getParentOverlayWidget() : reference,reference,child);
    injectionPoint=new AmendableWidgetReference(true,sibling,xPath,child.getNamespaceURI(),child.getType(),sibling ? (injectionPosition - reference.getParentOverlayWidget().getChildOverlayWidgets().indexOf(reference)) : injectionPosition);
  }
 else {
    injectionPoint=new AmendableWidgetReference(false,false,xPath,reference.getNamespaceURI(),reference.getType(),-1);
  }
  injectionPoint.setReferenceID(UUID.uuid());
  LOG.info("String_Node_Str" + injectionPoint);
  return injectionPoint;
}
Program: 87370
Project: 87370
Buggy source:
@Override public int getInjectionPosition(){
  if (injectionPosition == null)   throw new RuntimeException("String_Node_Str");
  return injectionPosition;
}

Fixed version (ground truth):
@Override public int getInjectionPosition(){
  if (amendment.getSourceReference() == null)   throw new RuntimeException("String_Node_Str");
  return amendment.getSourceReference().getOffset();
}
Program: 87371
Project: 87371
Buggy source:
/** 
 * Get the number for a given <tt>overlayWidget</tt>. The reported number depends various cases, but can be thought of in general that if the   {@link NumberingType} is constant, the {@link org.nsesa.editor.gwt.core.client.ui.overlay.document.OverlayWidget#getTypeIndex()}will instead be used to remove confusion about the path.
 * @param overlayWidget the overlay widget to get the number for
 * @param languageIso   the ISO code of the language
 * @return the number, should never return <tt>null</tt>
 */
@Override public String getNum(final OverlayWidget overlayWidget,final String languageIso){
  String index;
  if (overlayWidget.isIntroducedByAnAmendment()) {
    final OverlayWidget previous=overlayWidget.getPreviousSibling(new OverlayWidgetSelector(){
      @Override public boolean select(      OverlayWidget toSelect){
        return !toSelect.isIntroducedByAnAmendment() && overlayWidget.getType().equalsIgnoreCase(toSelect.getType());
      }
    }
);
    if (previous == null) {
      OverlayWidget next=overlayWidget.getNextSibling(new OverlayWidgetSelector(){
        @Override public boolean select(        OverlayWidget toSelect){
          return !toSelect.isIntroducedByAnAmendment() && overlayWidget.getType().equalsIgnoreCase(toSelect.getType());
        }
      }
);
      if (next == null) {
        index=Integer.toString(overlayWidget.getTypeIndex(true) + 1);
      }
 else {
        index="String_Node_Str" + NumberingType.LETTER.get(overlayWidget.getTypeIndex(true));
      }
    }
 else {
      String previousIndex=previous.getUnformattedIndex() != null ? previous.getUnformattedIndex() : Integer.toString(previous.getTypeIndex() + 1);
      int offset=overlayWidget.getTypeIndex(true) - previous.getTypeIndex();
      previousIndex+=NumberingType.LETTER.get(offset - 1);
      index=previousIndex;
    }
    return index + "String_Node_Str" + getNewNotation(languageIso);
  }
 else {
    final NumberingType numberingType=overlayWidget.getNumberingType();
    if (numberingType != null) {
      if (!numberingType.isConstant()) {
        final String unformattedIndex=overlayWidget.getUnformattedIndex();
        if (unformattedIndex != null) {
          return unformattedIndex;
        }
      }
    }
    return Integer.toString(overlayWidget.getTypeIndex() + 1);
  }
}

Fixed version (ground truth):
/** 
 * Get the number for a given <tt>overlayWidget</tt>. The reported number depends various cases, but can be thought of in general that if the   {@link NumberingType} is constant, the {@link org.nsesa.editor.gwt.core.client.ui.overlay.document.OverlayWidget#getTypeIndex()}will instead be used to remove confusion about the path.
 * @param overlayWidget the overlay widget to get the number for
 * @param languageIso   the ISO code of the language
 * @return the number, should never return <tt>null</tt>
 */
@Override public String getNum(final OverlayWidget overlayWidget,final String languageIso){
}
Program: 87372
Project: 87372
Buggy source:
@Override public int getInjectionPosition(OverlayWidget parent,OverlayWidget reference,OverlayWidget child){
  return reference.getChildOverlayWidgets().size();
}

Fixed version (ground truth):
@Override public int getInjectionPosition(OverlayWidget parent,OverlayWidget reference,OverlayWidget child){
  boolean sibling=parent != reference;
  if (sibling) {
    return reference.getParentOverlayWidget().getChildOverlayWidgets().indexOf(reference) + 1;
  }
 else {
    return reference.getChildOverlayWidgets().size() - 1;
  }
}
Program: 87374
Project: 87374
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + type + "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + type + "String_Node_Str"+ origin+ "String_Node_Str";
}
Program: 87375
Project: 87375
Buggy source:
/** 
 * Set the active overlay widget
 * @param activeOverlayWidget the active overlay widget
 */
public void setActiveOverlayWidget(OverlayWidget activeOverlayWidget){
  if (this.activeOverlayWidget != null) {
    activeOverlayWidget.asWidget().removeStyleName(style.selected());
  }
  LOG.info("String_Node_Str" + activeOverlayWidget + "String_Node_Str"+ documentController);
  this.activeOverlayWidget=activeOverlayWidget;
  if (this.activeOverlayWidget != null) {
    this.activeOverlayWidget.asWidget().addStyleName(style.selected());
  }
}

Fixed version (ground truth):
/** 
 * Set the active overlay widget
 * @param activeOverlayWidget the active overlay widget
 */
public void setActiveOverlayWidget(OverlayWidget activeOverlayWidget){
  if (this.activeOverlayWidget != null) {
    this.activeOverlayWidget.asWidget().removeStyleName(style.selected());
  }
  LOG.info("String_Node_Str" + activeOverlayWidget + "String_Node_Str"+ documentController);
  this.activeOverlayWidget=activeOverlayWidget;
  if (this.activeOverlayWidget != null) {
    this.activeOverlayWidget.asWidget().addStyleName(style.selected());
  }
}
Program: 87376
Project: 87376
Buggy source:
/** 
 * Resizes the dialog, centers and shows the popup.
 */
public void show(){
  overlayWidget.getParentOverlayWidget().asWidget().getElement().insertBefore(view.asWidget().getElement(),overlayWidget.getOverlayElement());
  view.getRichTextEditor().setHTML(overlayWidget.asWidget().getElement().getInnerHTML());
  adaptSize();
  view.asWidget().setVisible(true);
  view.init();
  view.getRichTextEditor().setOverlayWidget(overlayWidget);
  overlayWidget.asWidget().setVisible(false);
  showing=true;
}

Fixed version (ground truth):
/** 
 * Resizes the dialog, centers and shows the popup.
 */
public void show(){
  overlayWidget.getParentOverlayWidget().asWidget().getElement().insertBefore(view.asWidget().getElement(),overlayWidget.getOverlayElement());
  view.getRichTextEditor().setHTML(overlayWidget.asWidget().getElement().getInnerHTML());
  adaptSize();
  view.asWidget().setVisible(true);
  view.getRichTextEditor().setOverlayWidget(overlayWidget);
  view.init();
  overlayWidget.asWidget().setVisible(false);
  showing=true;
}
Program: 87377
Project: 87377
Buggy source:
public void setInjector(DocumentInjector documentInjector){
  if (documentInjector == null)   throw new UnsupportedOperationException("String_Node_Str");
  this.amendmentManager=documentInjector.getAmendmentManager();
  this.documentEventBus=documentInjector.getDocumentEventBus();
  this.view=documentInjector.getDocumentView();
  this.style=documentInjector.getDocumentViewCss();
  this.amendmentsPanelController=documentInjector.getAmendmentsPanelController();
  this.diffingManager=documentInjector.getDiffingManager();
  this.infoPanelController=documentInjector.getInfoPanelController();
  this.sourceFileController=documentInjector.getSourceFileController();
  this.documentHeaderController=documentInjector.getDocumentHeaderController();
  this.deadlineController=documentInjector.getDeadlineController();
  this.amendmentsHeaderController=documentInjector.getAmendmentsHeaderController();
  this.amendmentActionPanelController=documentInjector.getAmendmentActionPanelController();
  this.diffingManager.setDocumentController(this);
  this.amendmentManager.setDocumentController(this);
  this.amendmentManager.registerListeners();
  this.infoPanelController.setDocumentController(this);
  this.sourceFileController.setDocumentController(this);
  this.amendmentsPanelController.setDocumentController(this);
  this.documentHeaderController.setDocumentController(this);
  this.deadlineController.setDocumentController(this);
  this.amendmentsHeaderController.setDocumentController(this);
}

Fixed version (ground truth):
public void setInjector(DocumentInjector documentInjector){
  if (documentInjector == null)   throw new UnsupportedOperationException("String_Node_Str");
  this.amendmentManager=documentInjector.getAmendmentManager();
  this.localOverlayWidgetReferenceHandler=documentInjector.getLocalOverlayWidgetReferenceHandler();
  this.documentEventBus=documentInjector.getDocumentEventBus();
  this.view=documentInjector.getDocumentView();
  this.style=documentInjector.getDocumentViewCss();
  this.amendmentsPanelController=documentInjector.getAmendmentsPanelController();
  this.diffingManager=documentInjector.getDiffingManager();
  this.infoPanelController=documentInjector.getInfoPanelController();
  this.sourceFileController=documentInjector.getSourceFileController();
  this.documentHeaderController=documentInjector.getDocumentHeaderController();
  this.deadlineController=documentInjector.getDeadlineController();
  this.amendmentsHeaderController=documentInjector.getAmendmentsHeaderController();
  this.amendmentActionPanelController=documentInjector.getAmendmentActionPanelController();
  this.diffingManager.setDocumentController(this);
  this.amendmentManager.setDocumentController(this);
  this.amendmentManager.registerListeners();
  this.infoPanelController.setDocumentController(this);
  this.sourceFileController.setDocumentController(this);
  this.amendmentsPanelController.setDocumentController(this);
  this.documentHeaderController.setDocumentController(this);
  this.deadlineController.setDocumentController(this);
  this.amendmentsHeaderController.setDocumentController(this);
}
Program: 87378
Project: 87378
Buggy source:
/** 
 * Click callback; fires a   {@link OverlayWidgetSelectEvent} on the private document bus.
 * @param sender the overlay widget that was clicked
 */
@Override public void onClick(final OverlayWidget sender){
  documentEventBus.fireEvent(new OverlayWidgetSelectEvent(sender,documentController));
}

Fixed version (ground truth):
/** 
 * Click callback; fires a   {@link OverlayWidgetSelectEvent} on the private document bus.
 * @param sender the overlay widget that was clicked
 */
@Override public void onClick(final OverlayWidget sender,final Event event){
  String href=null;
  try {
    href=extractAttribute(event.getEventTarget(),"String_Node_Str");
  }
 catch (  Exception e) {
  }
  if (href != null && !"String_Node_Str".equals(href.trim())) {
    if (documentController != null && documentController.getLocalOverlayWidgetReferenceHandler() != null) {
      documentController.getLocalOverlayWidgetReferenceHandler().resolve("String_Node_Str",href,sender,new AsyncCallback<OverlayWidget>(){
        @Override public void onFailure(        Throwable caught){
        }
        @Override public void onSuccess(        OverlayWidget result){
          if (result != null)           scrollTo(result.asWidget());
        }
      }
);
    }
  }
  documentEventBus.fireEvent(new OverlayWidgetSelectEvent(sender,documentController));
}
Program: 87379
Project: 87379
Buggy source:
/** 
 * We ignore on-mouse-out events since they tend to be unreliable. Rather, we're passing the  {@link ActionBarController} as a single token around.
 * @param sender the overlay widget that lost the mouse hoover
 */
@Override public void onMouseOut(OverlayWidget sender){
}

Fixed version (ground truth):
/** 
 * We ignore on-mouse-out events since they tend to be unreliable. Rather, we're passing the  {@link ActionBarController} as a single token around.
 * @param sender the overlay widget that lost the mouse hoover
 */
@Override public void onMouseOut(final OverlayWidget sender,final Event event){
}