nus-yam/ex-repair huggingface dataset:
Program: 0
Project: 0
Buggy source:
@Test public void testGlobalSearch() throws Exception {
  this.testUtils.rest().delete(this.reference);
  this.testUtils.rest().savePage(this.reference);
  this.solrUtils.waitEmpyQueue();
  GetMethod getMethod=executeGet(URIUtil.encodeQuery(String.format("String_Node_Str" + this.pageName + "String_Node_Str",buildURI(WikisSearchQueryResource.class,getWiki()))));
  Assert.assertEquals(getHttpMethodInfo(getMethod),HttpStatus.SC_OK,getMethod.getStatusCode());
  SearchResults searchResults=(SearchResults)unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
  int resultSize=searchResults.getSearchResults().size();
  assertEquals(1,resultSize);
  assertEquals(this.fullName,searchResults.getSearchResults().get(0).getPageFullName());
}

Fixed version (ground truth):
@Test public void testGlobalSearch() throws Exception {
  this.testUtils.rest().delete(this.reference);
  this.testUtils.rest().savePage(this.reference);
  this.solrUtils.waitEmpyQueue();
  String query=String.format("String_Node_Str",this.pageName,buildURI(WikisSearchQueryResource.class,getWiki()));
  GetMethod getMethod=executeGet(URIUtil.encodeQuery(query));
  Assert.assertEquals(getHttpMethodInfo(getMethod),HttpStatus.SC_OK,getMethod.getStatusCode());
  SearchResults searchResults=(SearchResults)unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
  int resultSize=searchResults.getSearchResults().size();
  assertEquals(String.format("String_Node_Str",query),1,resultSize);
  assertEquals(this.fullName,searchResults.getSearchResults().get(0).getPageFullName());
}
Program: 1
Project: 1
Buggy source:
/** 
 * Returns the content of an HTTP/HTTPS URL as Bytes
 * @param surl url to retrieve
 * @return Content of the specified URL
 * @throws IOException
 */
public byte[] getURLContentAsBytes(String surl) throws IOException {
  try {
    return this.xwiki.getURLContentAsBytes(surl,this.context);
  }
 catch (  Exception e) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Returns the content of an HTTP/HTTPS URL as Bytes
 * @param surl url to retrieve
 * @return Content of the specified URL
 * @throws IOException
 */
@Programming public byte[] getURLContentAsBytes(String surl) throws IOException {
  if (!hasProgrammingRights()) {
    return null;
  }
  try {
    return this.xwiki.getURLContentAsBytes(surl,this.context);
  }
 catch (  Exception e) {
    return null;
  }
}
Program: 2
Project: 2
Buggy source:
/** 
 * Returns the content of an HTTP/HTTPS URL
 * @param surl url to retrieve
 * @param timeout manuel timeout in milliseconds
 * @return Content of the specified URL
 * @throws IOException
 */
public String getURLContent(String surl,int timeout) throws IOException {
  try {
    return this.xwiki.getURLContent(surl,timeout,this.xwiki.getHttpUserAgent(this.context));
  }
 catch (  Exception e) {
    return "String_Node_Str";
  }
}

Fixed version (ground truth):
/** 
 * Returns the content of an HTTP/HTTPS URL
 * @param surl url to retrieve
 * @param timeout manuel timeout in milliseconds
 * @return Content of the specified URL
 * @throws IOException
 */
@Programming public String getURLContent(String surl,int timeout) throws IOException {
  if (!hasProgrammingRights()) {
    return "String_Node_Str";
  }
  try {
    return this.xwiki.getURLContent(surl,timeout,this.xwiki.getHttpUserAgent(this.context));
  }
 catch (  Exception e) {
    return "String_Node_Str";
  }
}
Program: 3
Project: 3
Buggy source:
/** 
 * @deprecated since 2.2M1 use {@link #getXClass(com.xpn.xwiki.XWikiContext)}
 */
@Deprecated public BaseClass getxWikiClass(XWikiContext context) throws XWikiException ;

Fixed version (ground truth):
/** 
 * @deprecated since 2.2M1 use {@link com.xpn.xwiki.objects.BaseObject#getXClass(com.xpn.xwiki.XWikiContext)}
 */
@Deprecated public BaseClass getxWikiClass(XWikiContext context) throws XWikiException ;
Program: 4
Project: 4
Buggy source:
/** 
 * Execute a reading request with parameters and return result. <p> Execute query by passing HQL request values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escaping yourself before calling them.
 * @param sql the HQL request.
 * @param nb the number of rows to return. If 0 then all rows are returned.
 * @param start the number of rows to skip. If 0 don't skip any row.
 * @param whereParams if not null add to <code>sql</code> a where clause based on a table of table containing fieldname, field value and compared symbol ("=", ">", etc.).
 * @param parameterValues the where clause values that replace the question marks (?).
 * @param context the XWiki context required for getting information about the execution context.
 * @return a list of XWikiDocument.
 * @throws XWikiException in case of error while performing the query.
 * @since XWiki Core 1.1.2, XWiki Core 1.2M2
 */
<T>List<T> search(String sql,int nb,int start,Object[][] whereParams,List<?> parameterValues,XWikiContext context) throws XWikiException ;

Fixed version (ground truth):
/** 
 * Execute a reading request with parameters and return result. <p> Execute query by passing HQL request values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escaping yourself before calling them.
 * @param sql the HQL request.
 * @param nb the number of rows to return. If 0 then all rows are returned.
 * @param start the number of rows to skip. If 0 don't skip any row.
 * @param whereParams if not null add to {@code sql} a where clause based on a table of table containing fieldname, field value and compared symbol ("=", ">", etc.).
 * @param parameterValues the where clause values that replace the question marks (?).
 * @param context the XWiki context required for getting information about the execution context.
 * @return a list of XWikiDocument.
 * @throws XWikiException in case of error while performing the query.
 * @since XWiki Core 1.1.2, XWiki Core 1.2M2
 */
<T>List<T> search(String sql,int nb,int start,Object[][] whereParams,List<?> parameterValues,XWikiContext context) throws XWikiException ;
Program: 5
Project: 5
Buggy source:
/** 
 * API allowing to count the total number of documents that would be returned by a parameterized query.
 * @param parametrizedSqlClause Parameterized query to use, similar to the ones accepted by{@link #searchDocuments(String,List,XWikiContext)}. It should not contain <code>order by</code> or <code>group</code> clauses, since this kind of queries are not portable.
 * @param parameterValues The parameter values that replace the question marks.
 * @return The number of documents that matched the query.
 * @param context The current request context.
 * @throws XWikiException if there was a problem executing the query.
 */
int countDocuments(String parametrizedSqlClause,List<?> parameterValues,XWikiContext context) throws XWikiException ;

Fixed version (ground truth):
/** 
 * API allowing to count the total number of documents that would be returned by a parameterized query.
 * @param parametrizedSqlClause Parameterized query to use, similar to the ones accepted by{@link #searchDocuments(String,List,XWikiContext)}. It should not contain   {@code order by} or{@code group} clauses, since this kind of queries are not portable.
 * @param parameterValues The parameter values that replace the question marks.
 * @return The number of documents that matched the query.
 * @param context The current request context.
 * @throws XWikiException if there was a problem executing the query.
 */
int countDocuments(String parametrizedSqlClause,List<?> parameterValues,XWikiContext context) throws XWikiException ;
Program: 7
Project: 7
Buggy source:
@Override public Boolean apply(WebDriver driver){
  try {
    String value=getLocationPreview().getPathAsString();
    currentValue.setLength(0);
    currentValue.append(currentValue);
    return expectedContent.equals(value);
  }
 catch (  NotFoundException e) {
    return false;
  }
catch (  StaleElementReferenceException e) {
    return false;
  }
}

Fixed version (ground truth):
@Override public Boolean apply(WebDriver driver){
  try {
    String value=getLocationPreview().getPathAsString();
    currentValue.setLength(0);
    currentValue.append(value);
    return expectedContent.equals(value);
  }
 catch (  NotFoundException e) {
    return false;
  }
catch (  StaleElementReferenceException e) {
    return false;
  }
}
Program: 8
Project: 8
Buggy source:
/** 
 * Wait for the Location Preview Breadcrumb to display the passed content and throws an exception if the timeout is reached. Note that we need to wait since the Breadcrumb is udated live and asserting its content without waiting would lead to false positives.
 * @param expectedContent the content to wait for
 * @since 7.2RC1
 */
public void waitForLocationPreviewContent(final String expectedContent){
  final StringBuilder currentValue=new StringBuilder();
  try {
    getDriver().waitUntilCondition(new ExpectedCondition<Boolean>(){
      @Override public Boolean apply(      WebDriver driver){
        try {
          String value=getLocationPreview().getPathAsString();
          currentValue.setLength(0);
          currentValue.append(currentValue);
          return expectedContent.equals(value);
        }
 catch (        NotFoundException e) {
          return false;
        }
catch (        StaleElementReferenceException e) {
          return false;
        }
      }
    }
);
  }
 catch (  WebDriverException e) {
    throw new WebDriverException(String.format("String_Node_Str",currentValue.toString(),expectedContent),e);
  }
}

Fixed version (ground truth):
/** 
 * Wait for the Location Preview Breadcrumb to display the passed content and throws an exception if the timeout is reached. Note that we need to wait since the Breadcrumb is udated live and asserting its content without waiting would lead to false positives.
 * @param expectedContent the content to wait for
 * @since 7.2RC1
 */
public void waitForLocationPreviewContent(final String expectedContent){
  final StringBuilder currentValue=new StringBuilder();
  try {
    getDriver().waitUntilCondition(new ExpectedCondition<Boolean>(){
      @Override public Boolean apply(      WebDriver driver){
        try {
          String value=getLocationPreview().getPathAsString();
          currentValue.setLength(0);
          currentValue.append(value);
          return expectedContent.equals(value);
        }
 catch (        NotFoundException e) {
          return false;
        }
catch (        StaleElementReferenceException e) {
          return false;
        }
      }
    }
);
  }
 catch (  WebDriverException e) {
    throw new WebDriverException(String.format("String_Node_Str",currentValue.toString(),expectedContent),e);
  }
}
Program: 9
Project: 9
Buggy source:
@Override protected ComponentManager getComponentManagerInternal(){
  EntityReference entityReference=getCurrentReference();
  if (entityReference == null) {
    return null;
  }
  ExecutionContext econtext=this.execution.getContext();
  String contextKey=getClass().getName();
  EntityComponentManagerInstance contextComponentManager=(EntityComponentManagerInstance)econtext.getProperty(contextKey);
  if (contextComponentManager != null && contextComponentManager.entityReference.equals(entityReference)) {
    return contextComponentManager.componentManager;
  }
  ComponentManager componentManager=super.getComponentManagerInternal();
  econtext.setProperty(contextKey,new EntityComponentManagerInstance(entityReference,componentManager));
  return componentManager;
}

Fixed version (ground truth):
@Override protected ComponentManager getComponentManagerInternal(){
  EntityReference entityReference=getCurrentReference();
  if (entityReference == null) {
    return null;
  }
  ExecutionContext econtext=this.execution.getContext();
  if (econtext == null) {
    return super.getComponentManagerInternal();
  }
  String contextKey=getClass().getName();
  EntityComponentManagerInstance contextComponentManager=(EntityComponentManagerInstance)econtext.getProperty(contextKey);
  if (contextComponentManager != null && contextComponentManager.entityReference.equals(entityReference)) {
    return contextComponentManager.componentManager;
  }
  ComponentManager componentManager=super.getComponentManagerInternal();
  econtext.setProperty(contextKey,new EntityComponentManagerInstance(entityReference,componentManager));
  return componentManager;
}
Program: 10
Project: 10
Buggy source:
private void createWikiFromTemplate(){
  WikiIndexPage wikiIndexPage=WikiIndexPage.gotoPage();
  CreateWikiPage createWikiPage=wikiIndexPage.createWiki();
  createWikiPage.setPrettyName("String_Node_Str");
  String wikiName=createWikiPage.getComputedName();
  assertEquals("String_Node_Str",wikiName);
  createWikiPage.setTemplate(TEMPLATE_WIKI_ID);
  createWikiPage.setIsTemplate(false);
  createWikiPage.setDescription("String_Node_Str");
  CreateWikiPageStepUser createWikiPageStepUser=createWikiPage.goUserStep();
  WikiCreationPage wikiCreationPage=createWikiPageStepUser.create();
  assertEquals("String_Node_Str",wikiCreationPage.getStepTitle());
  wikiCreationPage.waitForFinalizeButton(30);
  assertFalse(wikiCreationPage.hasLogError());
  WikiHomePage wikiHomePage=wikiCreationPage.finalizeCreation();
  assertEquals(wikiHomePage.getContent(),TEMPLATE_CONTENT);
  DeleteWikiPage deleteWikiPage=wikiHomePage.deleteWiki();
  deleteWikiPage=deleteWikiPage.confirm("String_Node_Str");
  assertTrue(deleteWikiPage.hasUserErrorMessage());
  assertTrue(deleteWikiPage.hasWikiDeleteConfirmationInput("String_Node_Str"));
  deleteWikiPage=deleteWikiPage.confirm("String_Node_Str");
  assertTrue(deleteWikiPage.hasUserErrorMessage());
  assertTrue(deleteWikiPage.hasWikiDeleteConfirmationInput("String_Node_Str"));
  deleteWikiPage=deleteWikiPage.confirm("String_Node_Str");
  assertTrue(deleteWikiPage.hasSuccessMessage());
  wikiIndexPage=WikiIndexPage.gotoPage().waitUntilPageIsLoaded();
  assertNull(wikiIndexPage.getWikiLink("String_Node_Str"));
}

Fixed version (ground truth):
private void createWikiFromTemplate(){
  WikiIndexPage wikiIndexPage=WikiIndexPage.gotoPage();
  CreateWikiPage createWikiPage=wikiIndexPage.createWiki();
  createWikiPage.setPrettyName("String_Node_Str");
  String wikiName=createWikiPage.getComputedName();
  assertEquals("String_Node_Str",wikiName);
  createWikiPage.setTemplate(TEMPLATE_WIKI_ID);
  createWikiPage.setIsTemplate(false);
  createWikiPage.setDescription("String_Node_Str");
  CreateWikiPageStepUser createWikiPageStepUser=createWikiPage.goUserStep();
  WikiCreationPage wikiCreationPage=createWikiPageStepUser.create();
  assertEquals("String_Node_Str",wikiCreationPage.getStepTitle());
  wikiCreationPage.waitForFinalizeButton(60);
  assertFalse(wikiCreationPage.hasLogError());
  WikiHomePage wikiHomePage=wikiCreationPage.finalizeCreation();
  assertEquals(wikiHomePage.getContent(),TEMPLATE_CONTENT);
  DeleteWikiPage deleteWikiPage=wikiHomePage.deleteWiki();
  deleteWikiPage=deleteWikiPage.confirm("String_Node_Str");
  assertTrue(deleteWikiPage.hasUserErrorMessage());
  assertTrue(deleteWikiPage.hasWikiDeleteConfirmationInput("String_Node_Str"));
  deleteWikiPage=deleteWikiPage.confirm("String_Node_Str");
  assertTrue(deleteWikiPage.hasUserErrorMessage());
  assertTrue(deleteWikiPage.hasWikiDeleteConfirmationInput("String_Node_Str"));
  deleteWikiPage=deleteWikiPage.confirm("String_Node_Str");
  assertTrue(deleteWikiPage.hasSuccessMessage());
  wikiIndexPage=WikiIndexPage.gotoPage().waitUntilPageIsLoaded();
  assertNull(wikiIndexPage.getWikiLink("String_Node_Str"));
}
Program: 11
Project: 11
Buggy source:
@Override protected Address convertToType(Type targetType,Object value){
  if (value == null) {
    return null;
  }
  if (value instanceof Address) {
    return (Address)value;
  }
  Address address;
  try {
    address=InternetAddress.parse(value.toString())[0];
  }
 catch (  AddressException e) {
    throw new ConversionException(String.format("String_Node_Str",value,Address.class.getName()),e);
  }
  return address;
}

Fixed version (ground truth):
@Override protected Address convertToType(Type targetType,Object value){
  if (value == null) {
    return null;
  }
  Address address;
  try {
    address=InternetAddress.parse(value.toString())[0];
  }
 catch (  AddressException e) {
    throw new ConversionException(String.format("String_Node_Str",value,Address.class.getName()),e);
  }
  return address;
}
Program: 12
Project: 12
Buggy source:
@Override protected <G extends Message.RecipientType>G convertToType(Type targetType,Object value){
  if (value == null) {
    return null;
  }
  if (value instanceof Message.RecipientType[]) {
    return (G)value;
  }
  Message.RecipientType recipientType;
  String valueAsString=value.toString();
  if (valueAsString.equalsIgnoreCase("String_Node_Str")) {
    recipientType=Message.RecipientType.TO;
  }
 else   if (valueAsString.equalsIgnoreCase("String_Node_Str")) {
    recipientType=Message.RecipientType.CC;
  }
 else   if (valueAsString.equalsIgnoreCase("String_Node_Str")) {
    recipientType=Message.RecipientType.BCC;
  }
 else   if (valueAsString.equalsIgnoreCase("String_Node_Str")) {
    recipientType=MimeMessage.RecipientType.NEWSGROUPS;
  }
 else {
    throw new ConversionException(String.format("String_Node_Str",value,Message.RecipientType.class.getName()));
  }
  return (G)recipientType;
}

Fixed version (ground truth):
@Override protected <G extends Message.RecipientType>G convertToType(Type targetType,Object value){
  if (value == null) {
    return null;
  }
  Message.RecipientType recipientType;
  String valueAsString=value.toString();
  if (valueAsString.equalsIgnoreCase("String_Node_Str")) {
    recipientType=Message.RecipientType.TO;
  }
 else   if (valueAsString.equalsIgnoreCase("String_Node_Str")) {
    recipientType=Message.RecipientType.CC;
  }
 else   if (valueAsString.equalsIgnoreCase("String_Node_Str")) {
    recipientType=Message.RecipientType.BCC;
  }
 else   if (valueAsString.equalsIgnoreCase("String_Node_Str")) {
    recipientType=MimeMessage.RecipientType.NEWSGROUPS;
  }
 else {
    throw new ConversionException(String.format("String_Node_Str",value,Message.RecipientType.class.getName()));
  }
  return (G)recipientType;
}
Program: 13
Project: 13
Buggy source:
@Test public void convert() throws Exception {
  InternetAddress address=new InternetAddress("String_Node_Str");
  assertEquals(address,this.mocker.getComponentUnderTest().convert(Address.class,"String_Node_Str"));
  try {
    this.mocker.getComponentUnderTest().convert(Address.class,"String_Node_Str");
    fail("String_Node_Str");
  }
 catch (  ConversionException e) {
    assertEquals("String_Node_Str",e.getMessage());
  }
}

Fixed version (ground truth):
@Test public void convert() throws Exception {
  InternetAddress address=new InternetAddress("String_Node_Str");
  assertEquals(address,this.mocker.getComponentUnderTest().convert(Address.class,"String_Node_Str"));
}
Program: 14
Project: 14
Buggy source:
@Test public void convert() throws Exception {
  InternetAddress[] addresses=new InternetAddress[2];
  addresses[0]=new InternetAddress("String_Node_Str");
  addresses[1]=new InternetAddress("String_Node_Str");
  assertArrayEquals(addresses,(InternetAddress[])this.mocker.getComponentUnderTest().convert(Address[].class,"String_Node_Str"));
  try {
    this.mocker.getComponentUnderTest().convert(Address[].class,"String_Node_Str");
    fail("String_Node_Str");
  }
 catch (  ConversionException e) {
    assertEquals("String_Node_Str",e.getMessage());
  }
}

Fixed version (ground truth):
@Test public void convert() throws Exception {
  InternetAddress[] addresses=new InternetAddress[2];
  addresses[0]=new InternetAddress("String_Node_Str");
  addresses[1]=new InternetAddress("String_Node_Str");
  assertArrayEquals(addresses,(InternetAddress[])this.mocker.getComponentUnderTest().convert(Address[].class,"String_Node_Str"));
}
Program: 15
Project: 15
Buggy source:
@Test public void convert() throws Exception {
  assertEquals(Message.RecipientType.TO,this.mocker.getComponentUnderTest().convert(Message.RecipientType.class,"String_Node_Str"));
  assertEquals("String_Node_Str",this.mocker.getComponentUnderTest().convert(String.class,Message.RecipientType.TO));
  assertEquals(Message.RecipientType.CC,this.mocker.getComponentUnderTest().convert(Message.RecipientType.class,"String_Node_Str"));
  assertEquals(Message.RecipientType.BCC,this.mocker.getComponentUnderTest().convert(Message.RecipientType.class,"String_Node_Str"));
  assertEquals(MimeMessage.RecipientType.NEWSGROUPS,this.mocker.getComponentUnderTest().convert(Message.RecipientType.class,"String_Node_Str"));
  try {
    this.mocker.getComponentUnderTest().convert(Message.RecipientType.class,"String_Node_Str");
    fail("String_Node_Str");
  }
 catch (  ConversionException e) {
    assertEquals("String_Node_Str",e.getMessage());
  }
}

Fixed version (ground truth):
@Test public void convert() throws Exception {
  assertEquals(Message.RecipientType.TO,this.mocker.getComponentUnderTest().convert(Message.RecipientType.class,"String_Node_Str"));
  assertEquals("String_Node_Str",this.mocker.getComponentUnderTest().convert(String.class,Message.RecipientType.TO));
  assertEquals(Message.RecipientType.CC,this.mocker.getComponentUnderTest().convert(Message.RecipientType.class,"String_Node_Str"));
  assertEquals(Message.RecipientType.BCC,this.mocker.getComponentUnderTest().convert(Message.RecipientType.class,"String_Node_Str"));
  assertEquals(MimeMessage.RecipientType.NEWSGROUPS,this.mocker.getComponentUnderTest().convert(Message.RecipientType.class,"String_Node_Str"));
}
Program: 16
Project: 16
Buggy source:
/** 
 * Get the attachment. This does not clone the attachment. To get a clone, use  {@link #restoreAttachment(XWikiAttachment,XWikiContext)}
 * @return the attachment which was deleted.
 */
public XWikiAttachment getAttachment(){
  return this.attachment;
}

Fixed version (ground truth):
/** 
 * Get the attachment. This does not clone the attachment. To get a clone, use   {@link #restoreAttachment(XWikiAttachment,XWikiContext)}
 * @return the attachment which was deleted.
 */
public XWikiAttachment getAttachment(){
  return this.attachment;
}
Program: 17
Project: 17
Buggy source:
/** 
 * Generate an ID which will be as collision resistant as possible. Because  {@link con.xpn.xwiki.doc.XWikiAttachment#getId()} returns an int cast to a long, this ID is guaranteed to beunique unless the same attachment is deleted twice in the same second or again in a second which will come around in another 136 years.
 * @param attachment the attachment to get an ID number for.
 * @param deleteDate the Date the attachment was deleted.
 * @return an ID number for this deleted attachment.
 */
private static long generateId(final XWikiAttachment attachment,final Date deleteDate){
  return (attachment.getId() << 32) ^ ((deleteDate.getTime() / 1000) & 0x00000000FFFFFFFFL);
}

Fixed version (ground truth):
/** 
 * Generate an ID which will be as collision resistant as possible. Because   {@link com.xpn.xwiki.doc.XWikiAttachment#getId()} returns an int cast to a long, this ID is guaranteed to be uniqueunless the same attachment is deleted twice in the same second or again in a second which will come around in another 136 years.
 * @param attachment the attachment to get an ID number for.
 * @param deleteDate the Date the attachment was deleted.
 * @return an ID number for this deleted attachment.
 */
private static long generateId(final XWikiAttachment attachment,final Date deleteDate){
  return (attachment.getId() << 32) ^ ((deleteDate.getTime() / 1000) & 0x00000000FFFFFFFFL);
}
Program: 18
Project: 18
Buggy source:
/** 
 * @param rcsArchive the RCS archive to import.
 * @throws Exception if getting a revision from the RCS archiveor deserializing an attachment from XML fails
 */
private void fromRCS(final Archive rcsArchive) throws Exception {
  if (rcsArchive == null) {
    return;
  }
  final Node[] nodes=rcsArchive.changeLog();
  for (int i=nodes.length - 1; i > -1; i--) {
    final Object[] lines=rcsArchive.getRevision(nodes[i].getVersion());
    final StringBuffer content=new StringBuffer();
    for (int j=0; j < lines.length; j++) {
      String line=lines[j].toString();
      content.append(line);
      if (j != lines.length - 1) {
        content.append("String_Node_Str");
      }
    }
    final XWikiAttachment rev=new XWikiAttachment();
    rev.fromXML(content.toString());
    rev.setDoc(this.getAttachment().getDoc());
    rev.setAttachment_archive(this);
    rev.setVersion(nodes[i].getVersion().toString());
    revisions.add(rev);
  }
}

Fixed version (ground truth):
/** 
 * @param rcsArchive the RCS archive to import.
 * @throws Exception if getting a revision from the RCS archive or deserializing an attachment from XML fails
 */
private void fromRCS(final Archive rcsArchive) throws Exception {
  if (rcsArchive == null) {
    return;
  }
  final Node[] nodes=rcsArchive.changeLog();
  for (int i=nodes.length - 1; i > -1; i--) {
    final Object[] lines=rcsArchive.getRevision(nodes[i].getVersion());
    final StringBuffer content=new StringBuffer();
    for (int j=0; j < lines.length; j++) {
      String line=lines[j].toString();
      content.append(line);
      if (j != lines.length - 1) {
        content.append("String_Node_Str");
      }
    }
    final XWikiAttachment rev=new XWikiAttachment();
    rev.fromXML(content.toString());
    rev.setDoc(this.getAttachment().getDoc());
    rev.setAttachment_archive(this);
    rev.setVersion(nodes[i].getVersion().toString());
    revisions.add(rev);
  }
}
Program: 19
Project: 19
Buggy source:
/** 
 * Convert this attachment archive into JRCS format.
 * @param context the XWikiContext for the request.
 * @return this archive in JRCS format.
 * @throws Exception if something goes wrong while serializing the attachment to XML or inserting itinto the RCS archive.
 */
private Archive toRCS(final XWikiContext context) throws Exception {
  final Version[] versions=this.getVersions();
  Archive rcsArch=null;
  for (  XWikiAttachment rev : this.revisions) {
    final String sdata=rev.toStringXML(true,false,context);
    final Object[] lines=ToString.stringToArray(sdata);
    if (rcsArch == null) {
      rcsArch=new Archive(lines,rev.getFilename(),rev.getVersion());
    }
 else {
      rcsArch.addRevision(lines,"String_Node_Str");
    }
  }
  return rcsArch;
}

Fixed version (ground truth):
/** 
 * Convert this attachment archive into JRCS format.
 * @param context the XWikiContext for the request.
 * @return this archive in JRCS format.
 * @throws Exception if something goes wrong while serializing the attachment to XML or inserting it into the RCSarchive.
 */
private Archive toRCS(final XWikiContext context) throws Exception {
  final Version[] versions=this.getVersions();
  Archive rcsArch=null;
  for (  XWikiAttachment rev : this.revisions) {
    final String sdata=rev.toStringXML(true,false,context);
    final Object[] lines=ToString.stringToArray(sdata);
    if (rcsArch == null) {
      rcsArch=new Archive(lines,rev.getFilename(),rev.getVersion());
    }
 else {
      rcsArch.addRevision(lines,"String_Node_Str");
    }
  }
  return rcsArch;
}
Program: 20
Project: 20
Buggy source:
/** 
 * Clone an attachment but not it's archive.  {@link ListAttachmentArchive#clone()} calls {@link XWikiAttachment#clone()}and if the attachment is associated with an archive it call clone the archive. This function prevents an infinite loop.
 * @param original an attachment to clone.
 * @return a clone of original which has no XWikiAttachmentArchive attached.
 */
private static XWikiAttachment cloneAttachment(final XWikiAttachment original){
  final XWikiAttachmentArchive arch=original.getAttachment_archive();
  try {
    original.setAttachment_archive(null);
    return (XWikiAttachment)original.clone();
  }
  finally {
    original.setAttachment_archive(arch);
  }
}

Fixed version (ground truth):
/** 
 * Clone an attachment but not it's archive.  {@link ListAttachmentArchive#clone()} calls {@link XWikiAttachment#clone()} and if the attachment is associated with an archive it call clone the archive. Thisfunction prevents an infinite loop.
 * @param original an attachment to clone.
 * @return a clone of original which has no XWikiAttachmentArchive attached.
 */
private static XWikiAttachment cloneAttachment(final XWikiAttachment original){
  final XWikiAttachmentArchive arch=original.getAttachment_archive();
  try {
    original.setAttachment_archive(null);
    return (XWikiAttachment)original.clone();
  }
  finally {
    original.setAttachment_archive(arch);
  }
}
Program: 21
Project: 21
Buggy source:
/** 
 * Constructor from List. Create a new instance of ListAttachmentArchive from a list of attachments.
 * @param revisions a List of XWikiAttachment revisions to put in this archive.All revisions are the same attachment and thus must have the same ID.
 */
public ListAttachmentArchive(final List<XWikiAttachment> revisions){
  if (revisions.size() == 0) {
    return;
  }
  this.revisions.addAll(revisions);
  Collections.sort(this.revisions,XWikiAttachmentVersionComparitor.INSTANCE);
  long id=revisions.get(0).getId();
  final String firstAttachName=revisions.get(0).getFilename();
  for (  XWikiAttachment attach : revisions) {
    if (attach.getId() != id) {
      throw new IllegalArgumentException("String_Node_Str" + attach.getFilename() + "String_Node_Str"+ "String_Node_Str"+ firstAttachName+ "String_Node_Str"+ "String_Node_Str");
    }
    attach.setAttachment_archive(this);
  }
  this.attachment=this.revisions.get(revisions.size() - 1);
}

Fixed version (ground truth):
/** 
 * Constructor from List. Create a new instance of ListAttachmentArchive from a list of attachments.
 * @param revisions a List of XWikiAttachment revisions to put in this archive. All revisions are the sameattachment and thus must have the same ID.
 */
public ListAttachmentArchive(final List<XWikiAttachment> revisions){
  if (revisions.size() == 0) {
    return;
  }
  this.revisions.addAll(revisions);
  Collections.sort(this.revisions,XWikiAttachmentVersionComparitor.INSTANCE);
  long id=revisions.get(0).getId();
  final String firstAttachName=revisions.get(0).getFilename();
  for (  XWikiAttachment attach : revisions) {
    if (attach.getId() != id) {
      throw new IllegalArgumentException("String_Node_Str" + attach.getFilename() + "String_Node_Str"+ "String_Node_Str"+ firstAttachName+ "String_Node_Str"+ "String_Node_Str");
    }
    attach.setAttachment_archive(this);
  }
  this.attachment=this.revisions.get(revisions.size() - 1);
}
Program: 23
Project: 23
Buggy source:
@Override public FileItem createItem(String fieldName,String contentType,boolean isFormField,String fileName){
  try {
    final DiskFileItem item=(DiskFileItem)super.createItem(fieldName,contentType,isFormField,fileName);
    item.getOutputStream();
    item.getStoreLocation().deleteOnExit();
    return item;
  }
 catch (  IOException e) {
    String path=System.getProperty("String_Node_Str");
    if (super.getRepository() != null) {
      path=super.getRepository().getPath();
    }
    throw new RuntimeException("String_Node_Str" + "String_Node_Str" + path + "String_Node_Str");
  }
}

Fixed version (ground truth):
public FileItem createItem(String fieldName,String contentType,boolean isFormField,String fileName){
  try {
    final DiskFileItem item=(DiskFileItem)super.createItem(fieldName,contentType,isFormField,fileName);
    item.getOutputStream();
    item.getStoreLocation().deleteOnExit();
    return item;
  }
 catch (  IOException e) {
    String path=System.getProperty("String_Node_Str");
    if (super.getRepository() != null) {
      path=super.getRepository().getPath();
    }
    throw new RuntimeException("String_Node_Str" + "String_Node_Str" + path + "String_Node_Str");
  }
}
Program: 25
Project: 25
Buggy source:
/** 
 * Create a new cache entry for a user rule entry, linking it to its parent and to all provided groups.
 * @param entry the security rule entry to cache.
 * @param groups the list of groups to link this entry to.
 * @param parentReference the reference to the parent to link to.
 * @throws ParentEntryEvictedException if the parents required are no more available in the cache.
 */
private SecurityCacheEntry(SecurityEntry entry,Collection<GroupSecurityReference> groups,SecurityReference parentReference) throws ParentEntryEvictedException {
  this.entry=entry;
  int parentSize=groups.size() + ((parentReference == null) ? 0 : 1);
  if (parentSize > 0) {
    this.parents=new ArrayList<SecurityCacheEntry>(parentSize);
    if (parentReference != null) {
      SecurityCacheEntry parent=DefaultSecurityCache.this.getEntry(parentReference);
      if (parent == null) {
        throw new ParentEntryEvictedException();
      }
      this.parents.add(parent);
      parent.addChild(this);
    }
    for (    GroupSecurityReference group : groups) {
      if (group.equals(parentReference)) {
        continue;
      }
      SecurityCacheEntry parent=(entry instanceof SecurityShadowEntry && group.isGlobal()) ? DefaultSecurityCache.this.getShadowEntry(group,((SecurityShadowEntry)entry).getWikiReference()) : DefaultSecurityCache.this.getEntry(group);
      if (parent == null) {
        throw new ParentEntryEvictedException();
      }
      this.parents.add(parent);
      parent.addChild(this);
    }
    logNewEntry();
  }
 else {
    this.parents=null;
    logNewEntry();
  }
}

Fixed version (ground truth):
/** 
 * Create a new cache entry for a user rule entry, linking it to its parent and to all provided groups.
 * @param entry the security rule entry to cache.
 * @param groups the list of groups to link this entry to.
 * @param parentReference the reference to the parent to link to.
 * @throws ParentEntryEvictedException if the parents required are no more available in the cache.
 */
private SecurityCacheEntry(SecurityEntry entry,Collection<GroupSecurityReference> groups,SecurityReference parentReference) throws ParentEntryEvictedException {
  this.entry=entry;
  int parentSize=groups.size() + ((parentReference == null) ? 0 : 1);
  if (parentSize > 0) {
    this.parents=new ArrayList<SecurityCacheEntry>(parentSize);
    if (parentReference != null) {
      SecurityCacheEntry parent=DefaultSecurityCache.this.getEntry(parentReference);
      if (parent == null) {
        throw new ParentEntryEvictedException();
      }
      this.parents.add(parent);
      parent.addChild(this);
    }
    addParentGroups(groups,parentReference);
    logNewEntry();
  }
 else {
    this.parents=null;
    logNewEntry();
  }
}
Program: 26
Project: 26
Buggy source:
/** 
 * @param key the key of the cache slot to check.
 * @param entry the entry to compare to.
 * @return true, if the given entry has been inserted by another thread, false if the slot is available.
 * @throws ConflictingInsertionException if another thread use this slot with a different entry.
 */
private boolean isAlreadyInserted(String key,SecurityEntry entry) throws ConflictingInsertionException {
  SecurityCacheEntry oldEntry=cache.get(key);
  if (oldEntry != null) {
    if (!oldEntry.getEntry().equals(entry)) {
      throw new ConflictingInsertionException();
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean isAlreadyInserted(String key,SecurityEntry entry,Collection<GroupSecurityReference> groups) throws ConflictingInsertionException, ParentEntryEvictedException {
  SecurityCacheEntry oldEntry=cache.get(key);
  if (oldEntry != null) {
    if (!oldEntry.getEntry().equals(entry)) {
      throw new ConflictingInsertionException();
    }
    oldEntry.updateParentGroups(groups);
    return true;
  }
  return false;
}
Program: 29
Project: 29
Buggy source:
@Override public WikiDescriptor create(String wikiId,String wikiAlias) throws WikiManagerException {
  XWikiContext context=xcontextProvider.get();
  XWiki xwiki=context.getWiki();
  try {
    xwiki.getStore().createWiki(wikiId,context);
  }
 catch (  Exception e) {
    logger.error(e.getMessage());
    throw new WikiManagerException(localizationManager.getTranslationPlain("String_Node_Str"));
  }
  try {
    xwiki.updateDatabase(wikiId,true,true,context);
  }
 catch (  Exception e) {
    logger.error(e.getMessage());
    throw new WikiManagerException(localizationManager.getTranslationPlain("String_Node_Str"));
  }
  return createDescriptor(wikiId,wikiAlias);
}

Fixed version (ground truth):
@Override public WikiDescriptor create(String wikiId,String wikiAlias) throws WikiManagerException {
  XWikiContext context=xcontextProvider.get();
  XWiki xwiki=context.getWiki();
  try {
    xwiki.getStore().createWiki(wikiId,context);
  }
 catch (  Exception e) {
    throw new WikiManagerException(localizationManager.getTranslationPlain("String_Node_Str"),e);
  }
  try {
    xwiki.updateDatabase(wikiId,true,true,context);
  }
 catch (  Exception e) {
    throw new WikiManagerException(localizationManager.getTranslationPlain("String_Node_Str"),e);
  }
  return createDescriptor(wikiId,wikiAlias);
}
Program: 30
Project: 30
Buggy source:
@Override public void delete(String wikiId) throws WikiManagerException {
  XWikiContext context=xcontextProvider.get();
  XWiki xwiki=context.getWiki();
  if (wikiId.equals(wikiDescriptorManager.getMainWikiId())) {
    throw new WikiManagerException("String_Node_Str");
  }
  try {
    xwiki.getStore().deleteWiki(wikiId,context);
  }
 catch (  XWikiException e) {
    throw new WikiManagerException("String_Node_Str");
  }
  try {
    XWikiDocument descriptorDocument=descriptorDocumentHelper.getDocumentFromWikiId(wikiId);
    xwiki.deleteDocument(descriptorDocument,context);
  }
 catch (  XWikiException e) {
    throw new WikiManagerException("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void delete(String wikiId) throws WikiManagerException {
  XWikiContext context=xcontextProvider.get();
  XWiki xwiki=context.getWiki();
  if (wikiId.equals(wikiDescriptorManager.getMainWikiId())) {
    throw new WikiManagerException("String_Node_Str");
  }
  try {
    xwiki.getStore().deleteWiki(wikiId,context);
  }
 catch (  XWikiException e) {
    throw new WikiManagerException(String.format("String_Node_Str",wikiId),e);
  }
  try {
    XWikiDocument descriptorDocument=descriptorDocumentHelper.getDocumentFromWikiId(wikiId);
    xwiki.deleteDocument(descriptorDocument,context);
  }
 catch (  XWikiException e) {
    throw new WikiManagerException(String.format("String_Node_Str",wikiId),e);
  }
}
Program: 31
Project: 31
Buggy source:
@Override public void write(BaseObject xobject,Object filter,BaseObjectFilter objectFilter,DocumentInstanceInputProperties properties) throws WikiStreamException {
  XWikiContext xcontext=this.xcontextProvider.get();
  FilterEventParameters objectParameters=new FilterEventParameters();
  objectParameters.put(WikiObjectFilter.PARAMETER_CLASS_REFERENCE,xobject.getClassName());
  objectParameters.put(WikiObjectFilter.PARAMETER_GUID,xobject.getGuid());
  objectParameters.put(WikiObjectFilter.PARAMETER_NUMBER,xobject.getNumber());
  objectFilter.beginWikiObject(xobject.getReference().getName(),objectParameters);
  BaseClass xclass=xobject.getXClass(xcontext);
  ((BaseClassEventGenerator)this.classEventGenerator).write(xclass,filter,objectFilter,properties);
  Iterator<BaseProperty<?>> it=xobject.getSortedIterator();
  while (it.hasNext()) {
    BaseProperty<?> xproperty=it.next();
    String pname=xproperty.getName();
    if (pname != null && !pname.trim().equals("String_Node_Str")) {
      ((BasePropertyEventGenerator)this.propertyEventGenerator).write(xproperty,filter,objectFilter,properties);
    }
  }
  objectFilter.endWikiObject(xobject.getReference().getName(),objectParameters);
}

Fixed version (ground truth):
@Override public void write(BaseObject xobject,Object filter,BaseObjectFilter objectFilter,DocumentInstanceInputProperties properties) throws WikiStreamException {
  XWikiContext xcontext=this.xcontextProvider.get();
  FilterEventParameters objectParameters=new FilterEventParameters();
  objectParameters.put(WikiObjectFilter.PARAMETER_CLASS_REFERENCE,xobject.getClassName());
  objectParameters.put(WikiObjectFilter.PARAMETER_GUID,xobject.getGuid());
  objectParameters.put(WikiObjectFilter.PARAMETER_NUMBER,xobject.getNumber());
  objectFilter.beginWikiObject(xobject.getReference().getName(),objectParameters);
  BaseClass xclass=xobject.getXClass(xcontext);
  ((BaseClassEventGenerator)this.classEventGenerator).write(xclass,filter,objectFilter,properties);
  Iterator<BaseProperty<?>> it=xobject.getSortedIterator();
  while (it.hasNext()) {
    BaseProperty<?> xproperty=it.next();
    String pname=xproperty.getName();
    if (pname != null && !pname.trim().equals("String_Node_Str")) {
      ((BasePropertyEventGenerator)this.propertyEventGenerator).write(xproperty,filter,objectFilter,(Map<String,Object>)properties);
    }
  }
  objectFilter.endWikiObject(xobject.getReference().getName(),objectParameters);
}
Program: 33
Project: 33
Buggy source:
public boolean matches(Object arg){
  return ((XWikiAttachment)arg).getFilename().equals("String_Node_Str");
}

Fixed version (ground truth):
@Override public boolean matches(Object arg){
  return ((XWikiAttachment)arg).getFilename().equals("String_Node_Str");
}
Program: 34
Project: 34
Buggy source:
private XWikiDocument importDocument(String resource,boolean interactive,String wiki) throws ComponentLookupException, Exception {
  DefaultPackageConfiguration configuration=new DefaultPackageConfiguration();
  if (interactive) {
    configuration.setInteractive(interactive);
    configuration.setJobStatus(this.mockJobStatus);
  }
  DocumentImporterHandler documentHandler=new DocumentImporterHandler(this.defaultPackager,getComponentManager(),wiki,this.importer);
  documentHandler.setConfiguration(configuration);
  InputStream is=getClass().getResourceAsStream(resource);
  this.defaultPackager.parseDocument(is,documentHandler);
  return documentHandler.getDocument();
}

Fixed version (ground truth):
private XWikiDocument importDocument(String resource,boolean interactive,String wiki) throws ComponentLookupException, Exception {
  DefaultPackageConfiguration configuration=new DefaultPackageConfiguration();
  if (interactive) {
    configuration.setInteractive(interactive);
    configuration.setJobStatus(this.mockJobStatus);
  }
  DocumentImporterHandler documentHandler=new DocumentImporterHandler(this.defaultPackager,getComponentManager(),wiki,this.importer);
  documentHandler.setConfiguration(configuration);
  InputStream is=getClass().getResourceAsStream(resource);
  try {
    this.defaultPackager.parseDocument(is,documentHandler);
  }
  finally {
    is.close();
  }
  return documentHandler.getDocument();
}
Program: 35
Project: 35
Buggy source:
public void describeTo(Description description){
  description.appendValue("String_Node_Str");
}

Fixed version (ground truth):
@Override public void describeTo(Description description){
  description.appendValue("String_Node_Str");
}
Program: 36
Project: 36
Buggy source:
/** 
 * Return ordered (ascendent) versions for the provided extension id.
 * @param id the id of the extensions for which to return versions
 * @param offset the offset from where to start returning versions
 * @param nb the maximum number of versions to return
 * @return the versions of the provided extension id
 * @throws ResolveException fail to find extension for provided id
 */
public IterableResult<Version> resolveVersions(String id,int offset,int nb) throws ResolveException {
  setError(null);
  IterableResult<Version> versions=null;
  try {
    versions=this.repositoryManager.resolveVersions(id,offset,nb);
  }
 catch (  Exception e) {
    setError(e);
  }
  return versions;
}

Fixed version (ground truth):
/** 
 * Return ordered (ascendent) versions for the provided extension id.
 * @param id the id of the extensions for which to return versions
 * @param offset the offset from where to start returning versions
 * @param nb the maximum number of versions to return
 * @return the versions of the provided extension id
 */
public IterableResult<Version> resolveVersions(String id,int offset,int nb){
  setError(null);
  IterableResult<Version> versions=null;
  try {
    versions=this.repositoryManager.resolveVersions(id,offset,nb);
  }
 catch (  Exception e) {
    setError(e);
  }
  return versions;
}
Program: 37
Project: 37
Buggy source:
private SyndFeed getFeed(SyndFeedInfo syndFeedInfo,String urlStr,HttpMethod method,int statusCode) throws IOException, FetcherException, FeedException {
  if (statusCode == HttpURLConnection.HTTP_NOT_MODIFIED && syndFeedInfo != null) {
    fireEvent(FetcherEvent.EVENT_TYPE_FEED_UNCHANGED,urlStr);
    return syndFeedInfo.getSyndFeed();
  }
  SyndFeed feed=retrieveFeed(urlStr,method);
  fireEvent(FetcherEvent.EVENT_TYPE_FEED_RETRIEVED,urlStr,feed);
  return feed;
}

Fixed version (ground truth):
private SyndFeed getFeed(SyndFeedInfo syndFeedInfo,String urlStr,HttpMethod method,int statusCode) throws IOException, FeedException {
  if (statusCode == HttpURLConnection.HTTP_NOT_MODIFIED && syndFeedInfo != null) {
    fireEvent(FetcherEvent.EVENT_TYPE_FEED_UNCHANGED,urlStr);
    return syndFeedInfo.getSyndFeed();
  }
  SyndFeed feed=retrieveFeed(urlStr,method);
  fireEvent(FetcherEvent.EVENT_TYPE_FEED_RETRIEVED,urlStr,feed);
  return feed;
}
Program: 38
Project: 38
Buggy source:
/** 
 * @param urlStr
 * @param method
 * @return
 * @throws IOException
 * @throws HttpException
 * @throws FetcherException
 * @throws FeedException
 */
private static SyndFeed retrieveFeed(String urlStr,HttpMethod method) throws IOException, FetcherException, FeedException {
  InputStream stream=null;
  if ((method.getResponseHeader("String_Node_Str") != null) && ("String_Node_Str".equalsIgnoreCase(method.getResponseHeader("String_Node_Str").getValue()))) {
    stream=new GZIPInputStream(method.getResponseBodyAsStream());
  }
 else {
    stream=method.getResponseBodyAsStream();
  }
  try {
    XmlReader reader=null;
    if (method.getResponseHeader("String_Node_Str") != null) {
      reader=new XmlReader(stream,method.getResponseHeader("String_Node_Str").getValue(),true);
    }
 else {
      reader=new XmlReader(stream,true);
    }
    return new SyndFeedInput().build(reader);
  }
  finally {
    if (stream != null) {
      stream.close();
    }
  }
}

Fixed version (ground truth):
private static SyndFeed retrieveFeed(String urlStr,HttpMethod method) throws IOException, FeedException {
  InputStream stream=null;
  if ((method.getResponseHeader("String_Node_Str") != null) && ("String_Node_Str".equalsIgnoreCase(method.getResponseHeader("String_Node_Str").getValue()))) {
    stream=new GZIPInputStream(method.getResponseBodyAsStream());
  }
 else {
    stream=method.getResponseBodyAsStream();
  }
  try {
    XmlReader reader=null;
    if (method.getResponseHeader("String_Node_Str") != null) {
      reader=new XmlReader(stream,method.getResponseHeader("String_Node_Str").getValue(),true);
    }
 else {
      reader=new XmlReader(stream,true);
    }
    return new SyndFeedInput().build(reader);
  }
  finally {
    if (stream != null) {
      stream.close();
    }
  }
}
Program: 40
Project: 40
Buggy source:
public void onFailure(Throwable caught){
  Window.alert(app.getTranslation("String_Node_Str"));
  super.onFailure(caught);
  jscallback(callback,value);
}

Fixed version (ground truth):
@Override public void onFailure(Throwable caught){
  Window.alert(app.getTranslation("String_Node_Str"));
  super.onFailure(caught);
  jscallback(callback,value);
}
Program: 41
Project: 41
Buggy source:
public void onModuleLoad(){
  app=new XWikiGWTDefaultApp();
  app.setName("String_Node_Str");
  loadJSApi(this);
}

Fixed version (ground truth):
@Override public void onModuleLoad(){
  app=new XWikiGWTDefaultApp();
  app.setName("String_Node_Str");
  loadJSApi(this);
}