nus-yam/ex-repair huggingface dataset:
Program: 101382
Project: 101382
Buggy source:
private void renameProject(String oldName,String newName){
  URI uri=version.getParent().getParent().absolutPath();
  File workspaceDir=new File(uri.toFileString());
  File projectDirectory=new File(workspaceDir,oldName);
  projectDirectory.renameTo(new File(workspaceDir,newName));
}

Fixed version (ground truth):
private void renameProject(String oldName,String newName){
  URI uri=getDomainObject().getParent().absolutPath();
  File workspaceDir=new File(uri.toFileString());
  File projectDirectory=new File(workspaceDir,oldName);
  projectDirectory.renameTo(new File(workspaceDir,newName));
}
Program: 101383
Project: 101383
Buggy source:
@Override public int size(){
  return super.size() + 1;
}

Fixed version (ground truth):
@Override public int size(){
  return super.size();
}
Program: 101384
Project: 101384
Buggy source:
public Property getLocale(){
  if (locale == null) {
    Locale userLocale=Locale.getDefault();
    if (MainDashboard.getCurrent() != null) {
      userLocale=MainDashboard.getCurrent().getLocale();
    }
    String displayName=projectLocale.getLocale().getDisplayName(userLocale);
    Button button=new SortableButton(displayName);
    button.setStyleName(Reindeer.BUTTON_LINK);
    button.addListener(new ClickListener(){
      @Override public void buttonClick(      ClickEvent event){
        ProjectVersion projectVersion=projectLocale.getParent();
        Project project=projectVersion.getParent();
        String version="String_Node_Str" + projectVersion.getName();
        MainDashboard.getCurrent().getBreadcrumbs().setPath(project.getName(),version,projectLocale.getLocale().toString());
      }
    }
);
    locale=new GenericProperty<Button>(Button.class,button);
  }
  return locale;
}

Fixed version (ground truth):
public Property getLocale(){
  if (locale == null) {
    Locale userLocale=Locale.getDefault();
    if (MainDashboard.getCurrent() != null) {
      userLocale=MainDashboard.getCurrent().getLocale();
    }
    String displayName=projectLocale.isMaster() ? "String_Node_Str" : projectLocale.getLocale().getDisplayName(userLocale);
    Button button=new SortableButton(displayName);
    button.setStyleName(Reindeer.BUTTON_LINK);
    button.addListener(new ClickListener(){
      @Override public void buttonClick(      ClickEvent event){
        ProjectVersion projectVersion=projectLocale.getParent();
        Project project=projectVersion.getParent();
        String version="String_Node_Str" + projectVersion.getName();
        MainDashboard.getCurrent().getBreadcrumbs().setPath(project.getName(),version,projectLocale.getLocale().toString());
      }
    }
);
    locale=new GenericProperty<Button>(Button.class,button);
  }
  return locale;
}
Program: 101385
Project: 101385
Buggy source:
private ProjectVersion getProjectVersion(Project project,String version){
  return project.getChild(version);
}

Fixed version (ground truth):
private ProjectVersion getProjectVersion(Project project,String version){
  if (version == null)   return project.getChildren().get(0);
  return project.getChild(version);
}
Program: 101387
Project: 101387
Buggy source:
@Override public void valueChange(ValueChangeEvent event){
  Object value=event.getProperty().getValue();
  if (value == null)   return;
  Item theItem=propertyPairContainer.getItem(value);
  currentItem=(PropertyPairItem)theItem;
  propertyToolArea.selectionChanged(currentItem,reviews.get((String)currentItem.getKey()),this);
  currentItem.getSourceProperty();
  keyLabel.setValue(currentItem.getKey());
  translated.setPropertyDataSource(currentItem.getTarget());
  orignal.setPropertyDataSource(currentItem.getSource());
  translatedComment.setPropertyDataSource(currentItem.getTargetComment());
  orignalComment.setPropertyDataSource(currentItem.getSourceComment());
  translated.setComponentError(null);
}

Fixed version (ground truth):
@Override public void valueChange(ValueChangeEvent event){
  Object value=event.getProperty().getValue();
  if (value == null)   return;
  Item theItem=propertyPairContainer.getItem(value);
  currentItem=(PropertyPairItem)theItem;
  propertyToolArea.selectionChanged(currentItem,reviews.get((String)currentItem.getKey()),this);
  currentItem.getSourceProperty();
  keyLabel.setValue(currentItem.getKey());
  translated.setPropertyDataSource(currentItem.getTarget());
  orignal.setPropertyDataSource(currentItem.getSource());
  translatedComment.setPropertyDataSource(currentItem.getTargetComment());
  orignalComment.setPropertyDataSource(currentItem.getSourceComment());
  applyValidation(currentItem.getTargetProperty());
}
Program: 101388
Project: 101388
Buggy source:
@Override public void textChange(TextChangeEvent event){
  setDirty(true);
  if (currentItem == null)   return;
  reviews.removeAll(currentItem.getKey());
  translated.setComponentError(null);
  currentItem.getTargetProperty().setValue(event.getText());
  Collection<Review> reviewList=reviewService.review(descriptor,currentItem.getSourceProperty(),currentItem.getTargetProperty());
  if (!reviewList.isEmpty()) {
    reviews.putAll((String)currentItem.getKey(),reviewList);
    List<ErrorMessage> errors=new ArrayList<ErrorMessage>(reviewList.size());
    for (    Review review : reviewList) {
      UserError error=new UserError(review.getMessage(),UserError.CONTENT_TEXT,ErrorMessage.ERROR);
      errors.add(error);
    }
    CompositeErrorMessage message=new CompositeErrorMessage(errors);
    translated.setComponentError(message);
  }
  table.refreshRowCache();
}

Fixed version (ground truth):
@Override public void textChange(TextChangeEvent event){
  setDirty(true);
  if (event.getComponent() != translated || currentItem == null)   return;
  de.jutzig.jabylon.properties.Property copy=EcoreUtil.copy(currentItem.getTargetProperty());
  copy.setValue(event.getText());
  applyValidation(copy);
}
Program: 101389
Project: 101389
Buggy source:
@Override public void saveProperties(PropertyFileDescriptor descriptor,PropertyFile file,boolean autoTranslate){
  try {
    queue.put(new PropertyTuple(descriptor,file,autoTranslate));
  }
 catch (  InterruptedException e) {
    throw new RuntimeException("String_Node_Str" + descriptor.fullPath(),e);
  }
}

Fixed version (ground truth):
@Override public void saveProperties(PropertyFileDescriptor descriptor,PropertyFile file,boolean autoTranslate){
  try {
    PropertyFileDescriptor adaptedDescriptor=workspace.cdoView().getObject(descriptor);
    queue.put(new PropertyTuple(adaptedDescriptor,file,autoTranslate));
  }
 catch (  InterruptedException e) {
    throw new RuntimeException("String_Node_Str" + descriptor.fullPath(),e);
  }
}
Program: 101391
Project: 101391
Buggy source:
@Override public void buttonClick(ClickEvent event){
  PropertyPersistenceService propertyPersistence=MainDashboard.getCurrent().getPropertyPersistence();
  propertyPersistence.saveProperties(descriptor,source);
  final int filledKeys=getFilledKeys(source);
  try {
    descriptor=TransactionUtil.commit(descriptor,new Modification<PropertyFileDescriptor,PropertyFileDescriptor>(){
      @Override public PropertyFileDescriptor apply(      PropertyFileDescriptor object){
        object.setKeys(filledKeys);
        object.updatePercentComplete();
        return object;
      }
    }
);
    setDirty(false);
    layout.getWindow().showNotification("String_Node_Str",descriptor.getLocation().lastSegment());
  }
 catch (  CommitException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void buttonClick(ClickEvent event){
  final int filledKeys=getFilledKeys(source);
  try {
    descriptor=TransactionUtil.commit(descriptor,new Modification<PropertyFileDescriptor,PropertyFileDescriptor>(){
      @Override public PropertyFileDescriptor apply(      PropertyFileDescriptor object){
        object.setKeys(filledKeys);
        object.updatePercentComplete();
        return object;
      }
    }
);
    PropertyPersistenceService propertyPersistence=MainDashboard.getCurrent().getPropertyPersistence();
    propertyPersistence.saveProperties(descriptor,source);
    setDirty(false);
    layout.getWindow().showNotification("String_Node_Str",descriptor.getLocation().lastSegment());
  }
 catch (  CommitException e) {
    e.printStackTrace();
  }
}
Program: 101393
Project: 101393
Buggy source:
/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @model
 * @generated
 */
void computeLocation();

Fixed version (ground truth):
/** 
 * <!-- begin-user-doc --> Computes the location according to the current locale and the location of the master. Does nothing if this is the master, or there is no master available <!-- end-user-doc -->
 * @model
 * @generated
 * @see #isMaster()
 * @see #getLocation()
 * @see #getVariant()
 */
void computeLocation();
Program: 101394
Project: 101394
Buggy source:
/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated NOT
 */
public void computeLocation(){
  if (isMaster())   return;
  Locale locale=getVariant();
  URI location=getMaster().getLocation();
  String filename=location.lastSegment();
  String extension=location.fileExtension();
  if (extension != null) {
    filename=filename.substring(0,filename.length() - extension.length() - 1);
    filename+="String_Node_Str";
    filename+=locale.toString();
    filename+="String_Node_Str";
    filename+=extension;
  }
  setLocation(location.trimSegments(1).appendSegment(filename));
}

Fixed version (ground truth):
/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated NOT
 */
public void computeLocation(){
  if (isMaster() || getMaster() == null)   return;
  Locale locale=getVariant();
  URI location=getMaster().getLocation();
  String filename=location.lastSegment();
  String extension=location.fileExtension();
  if (extension != null) {
    filename=filename.substring(0,filename.length() - extension.length() - 1);
    Locale masterLocale=getMaster().getVariant();
    if (masterLocale != null) {
      filename=filename.substring(0,filename.length() - (masterLocale.toString().length() + 1));
    }
    filename+="String_Node_Str";
    filename+=locale.toString();
    filename+="String_Node_Str";
    filename+=extension;
  }
  setLocation(location.trimSegments(1).appendSegment(filename));
}
Program: 101395
Project: 101395
Buggy source:
/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated NOT
 */
public boolean isMaster(){
  return !eIsSet(PropertiesPackage.Literals.PROPERTY_FILE_DESCRIPTOR__VARIANT);
}

Fixed version (ground truth):
/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated NOT
 */
public boolean isMaster(){
  ProjectLocale locale=getProjectLocale();
  if (locale == null)   return false;
  return locale.isMaster();
}
Program: 101396
Project: 101396
Buggy source:
/** 
 * Tests the '  {@link de.jutzig.jabylon.properties.PropertyFileDescriptor#isMaster() <em>Master</em>}' feature getter. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @see de.jutzig.jabylon.properties.PropertyFileDescriptor#isMaster()
 * @generated NOT
 */
public void testIsMaster(){
  assertTrue(getFixture().isMaster());
  getFixture().setVariant(Locale.FRENCH);
  assertFalse(getFixture().isMaster());
  getFixture().setVariant(null);
  assertTrue(getFixture().isMaster());
}

Fixed version (ground truth):
/** 
 * Tests the '  {@link de.jutzig.jabylon.properties.PropertyFileDescriptor#isMaster() <em>Master</em>}' feature getter. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @see de.jutzig.jabylon.properties.PropertyFileDescriptor#isMaster()
 * @generated NOT
 */
public void testIsMaster(){
  assertFalse(getFixture().isMaster());
  getFixture().setVariant(Locale.FRENCH);
  assertFalse(getFixture().isMaster());
  getFixture().setVariant(null);
  assertFalse(getFixture().isMaster());
  ProjectVersion version=PropertiesFactory.eINSTANCE.createProjectVersion();
  ProjectLocale master=PropertiesFactory.eINSTANCE.createProjectLocale();
  version.setMaster(master);
  master.getDescriptors().add(getFixture());
  assertTrue(getFixture().isMaster());
  ProjectLocale slave=PropertiesFactory.eINSTANCE.createProjectLocale();
  version.getLocales().add(slave);
  slave.getDescriptors().add(getFixture());
  assertFalse(getFixture().isMaster());
}
Program: 101397
Project: 101397
Buggy source:
/** 
 * Tests the '  {@link de.jutzig.jabylon.properties.PropertyFileDescriptor#computeLocation() <em>Compute Location</em>}' operation. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @see de.jutzig.jabylon.properties.PropertyFileDescriptor#computeLocation()
 * @generated
 */
public void testComputeLocation(){
  fail();
}

Fixed version (ground truth):
/** 
 * Tests the '  {@link de.jutzig.jabylon.properties.PropertyFileDescriptor#computeLocation() <em>Compute Location</em>}' operation. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @see de.jutzig.jabylon.properties.PropertyFileDescriptor#computeLocation()
 * @generated NOT
 */
public void testComputeLocation(){
  PropertyFileDescriptor master=PropertiesFactory.eINSTANCE.createPropertyFileDescriptor();
  master.setLocation(URI.createURI("String_Node_Str"));
  getFixture().setVariant(new Locale("String_Node_Str","String_Node_Str"));
  getFixture().computeLocation();
  assertNull(getFixture().getLocation());
  getFixture().setMaster(master);
  getFixture().computeLocation();
  assertEquals("String_Node_Str",getFixture().getLocation().toString());
}
Program: 101398
Project: 101398
Buggy source:
private Component createHeader(){
  Label title=new Label();
  title.setCaption("String_Node_Str");
  title.setStyleName(Reindeer.LABEL_H1);
  HorizontalLayout header=new HorizontalLayout();
  header.setWidth("String_Node_Str");
  header.setMargin(true);
  header.setSpacing(true);
  CssLayout titleLayout=new CssLayout();
  titleLayout.addComponent(title);
  Label description=new Label();
  description.setStyleName(Reindeer.LABEL_SMALL);
  description.setSizeUndefined();
  description.setCaption("String_Node_Str");
  titleLayout.addComponent(description);
  header.addComponent(titleLayout);
  BreadCrumbImpl crumbs=new BreadCrumbImpl();
  breadcrumbs=crumbs;
  titleLayout.addComponent(crumbs);
  return header;
}

Fixed version (ground truth):
private Component createHeader(){
  Label title=new Label();
  title.setCaption("String_Node_Str");
  title.setStyleName(Reindeer.LABEL_H1);
  HorizontalLayout header=new HorizontalLayout();
  header.setMargin(true);
  header.setSpacing(true);
  header.addComponent(title);
  BreadCrumbImpl crumbs=new BreadCrumbImpl();
  breadcrumbs=crumbs;
  header.addComponent(crumbs);
  return header;
}
Program: 101399
Project: 101399
Buggy source:
public void setMainComponent(Component c){
  horizontalSplit.setSecondComponent(c);
}

Fixed version (ground truth):
public void setMainComponent(Component c){
  if (mainComponent != null) {
    contentArea.removeComponent(mainComponent);
  }
  mainComponent=c;
  contentArea.addComponent(mainComponent);
}
Program: 101400
Project: 101400
Buggy source:
private void buildMainLayout(){
  setMainWindow(new Window("String_Node_Str"));
  VerticalLayout layout=new VerticalLayout();
  layout.setSizeFull();
  horizontalSplit=new HorizontalSplitPanel();
  layout.addComponent(createToolbar());
  Component header=createHeader();
  layout.addComponent(header);
  layout.addComponent(horizontalSplit);
  layout.setExpandRatio(horizontalSplit,1);
  horizontalSplit.setSplitPosition(200,Sizeable.UNITS_PIXELS);
  horizontalSplit.setCaption("String_Node_Str");
  horizontalSplit.setDescription("String_Node_Str");
  getMainWindow().setContent(layout);
  addProject=new Button();
  addProject.setCaption("String_Node_Str");
  addProject.addListener(new ClickListener(){
    @Override public void buttonClick(    ClickEvent event){
      setMainComponent(new NewProjectForm(workspace,MainDashboard.this));
    }
  }
);
  horizontalSplit.addComponent(addProject);
  setMainComponent(new ProjectListPanel());
}

Fixed version (ground truth):
private void buildMainLayout(){
  setMainWindow(new Window("String_Node_Str"));
  mainLayout=new VerticalLayout();
  contentArea=new GridLayout();
  contentArea.setSizeUndefined();
  Component header=createHeader();
  mainLayout.addComponent(header);
  mainLayout.setComponentAlignment(header,Alignment.TOP_LEFT);
  mainLayout.setExpandRatio(header,0f);
  mainLayout.addComponent(contentArea);
  getMainWindow().setContent(mainLayout);
}
Program: 101402
Project: 101402
Buggy source:
private void createContents(){
  Workspace workspace=MainDashboard.getCurrent().getWorkspace();
  EList<Project> projects=workspace.getProjects();
  setColumns(2);
  setRows(projects.size());
  buildHeader();
  Random random=new Random();
  for (  Project project : projects) {
    Button projectName=new Button(project.getName());
    projectName.setStyleName(Reindeer.BUTTON_LINK);
    addComponent(projectName);
    projectName.setData(project);
    projectName.addListener(this);
    StaticProgressIndicator progress=new StaticProgressIndicator();
    progress.setPercentage(random.nextInt(100));
    addComponent(progress);
  }
}

Fixed version (ground truth):
private void createContents(){
  Workspace workspace=MainDashboard.getCurrent().getWorkspace();
  EList<Project> projects=workspace.getProjects();
  setColumns(2);
  setRows(projects.size());
  buildHeader();
  Random random=new Random();
  for (  Project project : projects) {
    Button projectName=new Button(project.getName());
    projectName.setStyleName(Reindeer.BUTTON_LINK);
    addComponent(projectName);
    projectName.setData(project);
    projectName.addListener(this);
    StaticProgressIndicator progress=new StaticProgressIndicator();
    progress.setPercentage(random.nextInt(100));
    addComponent(progress);
  }
  Button addProject=new Button();
  addProject.setCaption("String_Node_Str");
  addProject.addListener(new ClickListener(){
    @Override public void buttonClick(    ClickEvent event){
      MainDashboard dashboard=MainDashboard.getCurrent();
      dashboard.setMainComponent(new NewProjectForm(dashboard));
    }
  }
);
  addComponent(addProject);
}
Program: 101403
Project: 101403
Buggy source:
public Property readProperty(BufferedReader reader) throws IOException {
  String line=null;
  Property property=null;
  StringBuilder comment=new StringBuilder();
  StringBuilder propertyValue=new StringBuilder();
  while ((line=reader.readLine()) != null) {
    line=line.trim();
    if (line.length() == 0)     continue;
    if (isComment(line) && line.length() > 1) {
      if (comment.length() > 0)       comment.append("String_Node_Str");
      comment.append(line.substring(1).trim());
    }
 else {
      propertyValue.append(NativeToAsciiConverter.convertEncodedToUnicode(line));
      if (line.endsWith("String_Node_Str")) {
        propertyValue.append("String_Node_Str");
        continue;
      }
      property=PropertiesFactory.eINSTANCE.createProperty();
      if (comment.length() > 0)       property.setComment(comment.toString());
      String[] parts=split(propertyValue.toString());
      property.setKey(parts[0]);
      property.setValue(parts[1]);
      return property;
    }
  }
  return property;
}

Fixed version (ground truth):
public Property readProperty(BufferedReader reader) throws IOException {
  String line=null;
  Property property=null;
  StringBuilder comment=new StringBuilder();
  StringBuilder propertyValue=new StringBuilder();
  while ((line=reader.readLine()) != null) {
    line=line.trim();
    if (line.length() == 0)     continue;
    if (isComment(line) && line.length() > 1) {
      if (comment.length() > 0)       comment.append("String_Node_Str");
      comment.append(line.substring(1).trim());
    }
 else {
      propertyValue.append(NativeToAsciiConverter.convertEncodedToUnicode(line));
      if (line.endsWith("String_Node_Str")) {
        propertyValue.append("String_Node_Str");
        continue;
      }
      property=PropertiesFactory.eINSTANCE.createProperty();
      if (comment.length() > 0)       property.setComment(comment.toString());
      String[] parts=split(propertyValue.toString());
      if (parts[0] == null)       continue;
      property.setKey(parts[0]);
      property.setValue(parts[1]);
      return property;
    }
  }
  return property;
}
Program: 101406
Project: 101406
Buggy source:
/** 
 * Calculate semantic relatedness between documents
 * @param doc1
 * @param doc2
 * @return returns relatedness if successful, -1 otherwise
 */
public double getRelatedness(String doc1,String doc2){
  try {
    IConceptVector c1;
    if ((c1=esaCache.get(doc1)) == null) {
      c1=getConceptVector(doc1);
      esaCache.put(doc1,c1);
    }
    IConceptVector c2;
    if ((c2=esaCache.get(doc2)) == null) {
      c2=getConceptVector(doc2);
      esaCache.put(doc2,c2);
    }
    System.err.println("String_Node_Str" + c1.count());
    System.err.println("String_Node_Str" + c2.count());
    return getRelatedness(c1,c2);
  }
 catch (  IOException ex) {
    Logger.getLogger(ESAAnalyzer.class.getName()).log(Level.SEVERE,null,ex);
    return -1;
  }
catch (  SQLException ex) {
    Logger.getLogger(ESAAnalyzer.class.getName()).log(Level.SEVERE,null,ex);
    return -1;
  }
}

Fixed version (ground truth):
/** 
 * Calculate semantic relatedness between documents
 * @param doc1
 * @param doc2
 * @return returns relatedness if successful, -1 otherwise
 */
public double getRelatedness(String doc1,String doc2){
  try {
    IConceptVector c1;
    if ((c1=esaCache.get(doc1)) == null) {
      c1=getConceptVector(doc1);
      esaCache.put(doc1,c1);
    }
    IConceptVector c2;
    if ((c2=esaCache.get(doc2)) == null) {
      c2=getConceptVector(doc2);
      esaCache.put(doc2,c2);
    }
    if (c1 == null || c2 == null)     return Double.NaN;
    System.err.println("String_Node_Str" + c1.count());
    System.err.println("String_Node_Str" + c2.count());
    return getRelatedness(c1,c2);
  }
 catch (  IOException ex) {
    Logger.getLogger(ESAAnalyzer.class.getName()).log(Level.SEVERE,null,ex);
    return -1;
  }
catch (  SQLException ex) {
    Logger.getLogger(ESAAnalyzer.class.getName()).log(Level.SEVERE,null,ex);
    return -1;
  }
}
Program: 101407
Project: 101407
Buggy source:
public static <T>T gmock(Class<T> classToMock){
  return Mockito.mock(classToMock,new GroovyAnswer(Mockito.RETURNS_DEFAULTS));
}

Fixed version (ground truth):
public static <T>T gmock(Class<T> classToMock){
  MockSettingsImpl mockSettings=(MockSettingsImpl)Mockito.withSettings().defaultAnswer(new GroovyAnswer(Mockito.RETURNS_DEFAULTS));
  T mock=Mockito.mock(classToMock,mockSettings);
  injectGroovyInterceptor((Factory)mock,mockSettings);
  return mock;
}
Program: 101408
Project: 101408
Buggy source:
@Override public Object intercept(Object proxy,Method method,Object[] args,MethodProxy methodProxy) throws Throwable {
  if (objectMethodsGuru.isGetMetaClass(method)) {
    return GroovySystem.getMetaClassRegistry().getMetaClass(method.getDeclaringClass());
  }
  return super.intercept(proxy,method,args,methodProxy);
}

Fixed version (ground truth):
@Override public Object intercept(Object proxy,Method method,Object[] args,MethodProxy methodProxy) throws Throwable {
  if (objectMethodsGuru.isGetMetaClass(method)) {
    return GroovySystem.getMetaClassRegistry().getMetaClass(typeToMock);
  }
  return super.intercept(proxy,method,args,methodProxy);
}
Program: 101409
Project: 101409
Buggy source:
public MethodInterceptorForGroovyFilter(InternalMockHandler handler,MockCreationSettings mockSettings){
  super(handler,mockSettings);
}

Fixed version (ground truth):
public MethodInterceptorForGroovyFilter(InternalMockHandler handler,MockCreationSettings mockSettings){
  super(handler,mockSettings);
  typeToMock=mockSettings.getTypeToMock();
}
Program: 101410
Project: 101410
Buggy source:
/** 
 * Construct a data entry.
 * @param name A name used for diagnostics.
 * @param data The data for this entry.
 * @param charset The character encoding for this entry.
 */
public DataEntry(String name,byte[] data,String charset){
  this.name=name;
  this.data=data.clone();
  this.charset=charset;
  this.keyEnd=SwordUtil.findByte(this.data,SEPARATOR);
}

Fixed version (ground truth):
/** 
 * Construct a data entry.
 * @param name A name used for diagnostics.
 * @param data The data for this entry.
 * @param charset The character encoding for this entry.
 */
public DataEntry(String name,byte[] data,String charset){
  this.name=name;
  this.data=data.clone();
  this.charset=charset;
  this.keyEnd=SwordUtil.findByte(this.data,SEP_NL);
}
Program: 101411
Project: 101411
Buggy source:
/** 
 * Get the key from this DataEntry.
 * @return the key
 */
public String getKey(){
  if (key == null) {
    if (keyEnd < 0) {
      log.error("String_Node_Str",name);
      return "String_Node_Str";
    }
    key=SwordUtil.decode(name,data,keyEnd,charset).trim();
    if (key.endsWith("String_Node_Str")) {
      key=key.substring(0,key.length() - 1);
    }
  }
  return key;
}

Fixed version (ground truth):
/** 
 * Get the key from this DataEntry.
 * @return the key
 */
public String getKey(){
  if (key == null) {
    if (data.length == 0) {
      key="String_Node_Str";
      return key;
    }
    if (keyEnd < 0) {
      key="String_Node_Str";
      return key;
    }
    int end=keyEnd;
    if (end > 0 && data[end - 1] == SEP_CR) {
      --end;
    }
    if (end > 0 && data[end - 1] == SEP_BSLASH) {
      --end;
    }
    if (end == 0) {
      key="String_Node_Str";
      return key;
    }
    key=SwordUtil.decode(name,data,end,charset);
  }
  return key;
}
Program: 101412
Project: 101412
Buggy source:
/** 
 * Get the position of the second \n in the data. This represents the end of the link and the start of the rest of the data.
 * @return the end of the link or -1 if not found.
 */
private int getLinkEnd(){
  if (linkEnd == 0) {
    linkEnd=SwordUtil.findByte(data,keyEnd + 1,SEPARATOR);
    if (linkEnd == -1) {
      linkEnd=data.length - 1;
    }
  }
  return linkEnd;
}

Fixed version (ground truth):
/** 
 * Get the position of the second \n in the data. This represents the end of the link and the start of the rest of the data.
 * @return the end of the link or -1 if not found.
 */
private int getLinkEnd(){
  if (linkEnd == 0) {
    linkEnd=SwordUtil.findByte(data,keyEnd + 1,SEP_NL);
    if (linkEnd == -1) {
      linkEnd=data.length - 1;
    }
  }
  return linkEnd;
}
Program: 101413
Project: 101413
Buggy source:
/** 
 * A helper class for the SwordInstaller to tell us that it has copied a new Book into our install directory
 * @param sbmd The SwordBookMetaData object for the new Book
 * @throws BookException
 */
public static void registerNewBook(SwordBookMetaData sbmd) throws BookException {
  BookDriver[] drivers=Books.installed().getDriversByClass(SwordBookDriver.class);
  for (int i=0; i < drivers.length; i++) {
    SwordBookDriver sdriver=(SwordBookDriver)drivers[i];
    Book book=sdriver.createBook(sbmd);
    Books.installed().addBook(book);
  }
}

Fixed version (ground truth):
/** 
 * A helper class for the SwordInstaller to tell us that it has copied a new Book into our install directory
 * @param sbmd The SwordBookMetaData object for the new Book
 * @throws BookException
 */
public static void registerNewBook(SwordBookMetaData sbmd) throws BookException {
  SwordBookMetaData bmd=null;
  URI bookDirURI=sbmd.getLibrary();
  File mods=new File(bookDirURI.getPath(),SwordConstants.DIR_CONF);
  String bookConf=sbmd.getBookConf();
  File configfile=new File(mods,bookConf);
  if (configfile.exists()) {
    try {
      bmd=new SwordBookMetaData(configfile,bookDirURI);
    }
 catch (    IOException e) {
      LOGGER.warn("String_Node_Str",e);
    }
  }
  if (bmd == null) {
    LOGGER.error("String_Node_Str");
    return;
  }
  if (!bmd.isSupported()) {
    LOGGER.error("String_Node_Str",bmd.getInitials(),bmd.getDriver(),bmd.getProperty(BookMetaData.KEY_VERSIFICATION),bmd.getBookType(),bmd.getBookCategory());
    return;
  }
  SwordBookDriver d=(SwordBookDriver)sbmd.getDriver();
  bmd.setDriver(d);
  Book book=d.createBook(bmd);
  Books.installed().addBook(book);
}
Program: 101414
Project: 101414
Buggy source:
private void load(Reader in,Filter<String> filter) throws IOException {
  BufferedReader bin=null;
  try {
    if (in instanceof BufferedReader) {
      bin=(BufferedReader)in;
    }
 else {
      bin=new BufferedReader(in,MAX_BUFF_SIZE);
    }
    while (true) {
      String line=advance(bin);
      if (line == null) {
        break;
      }
      if (isSectionLine(line)) {
        name=line.substring(1,line.length() - 1);
        continue;
      }
      int splitPos=getSplitPos(line);
      if (splitPos < 0) {
        warnings.append("String_Node_Str").append(line).append('\n');
        continue;
      }
      String key=line.substring(0,splitPos).trim();
      String value=more(bin,line.substring(splitPos + 1).trim());
      if (filter != null && filter.test(key)) {
        add(key,value);
      }
    }
    report=warnings.toString();
    warnings.setLength(0);
    warnings.trimToSize();
  }
  finally {
    if (bin != null) {
      bin.close();
      bin=null;
    }
  }
}

Fixed version (ground truth):
private void load(Reader in,Filter<String> filter) throws IOException {
  BufferedReader bin=null;
  try {
    if (in instanceof BufferedReader) {
      bin=(BufferedReader)in;
    }
 else {
      bin=new BufferedReader(in,MAX_BUFF_SIZE);
    }
    while (true) {
      String line=advance(bin);
      if (line == null) {
        break;
      }
      if (isSectionLine(line)) {
        name=line.substring(1,line.length() - 1);
        continue;
      }
      int splitPos=getSplitPos(line);
      if (splitPos < 0) {
        warnings.append("String_Node_Str").append(line).append('\n');
        continue;
      }
      String key=line.substring(0,splitPos).trim();
      String value=more(bin,line.substring(splitPos + 1).trim());
      if (filter == null || filter.test(key)) {
        add(key,value);
      }
    }
    report=warnings.toString();
    warnings.setLength(0);
    warnings.trimToSize();
  }
  finally {
    if (bin != null) {
      bin.close();
      bin=null;
    }
  }
}
Program: 101415
Project: 101415
Buggy source:
/** 
 * Load the conf from a buffer. This is used to load conf entries from the mods.d.tar.gz file.
 * @param buffer the buffer to load
 * @throws IOException
 */
private IniSection load(byte[] buffer,org.crosswire.common.util.Filter<String> keepers) throws IOException {
  IniSection config=new IniSection();
  config.load(buffer,ENCODING_UTF8,keepers);
  String encoding=config.get(KEY_ENCODING);
  if (!ENCODING_UTF8.equalsIgnoreCase(encoding)) {
    config.clear();
    config.load(buffer,ENCODING_LATIN1);
  }
  return config;
}

Fixed version (ground truth):
/** 
 * Load the conf from a buffer. This is used to load conf entries from the mods.d.tar.gz file.
 * @param buffer the buffer to load
 * @throws IOException
 */
private IniSection load(byte[] buffer,org.crosswire.common.util.Filter<String> keepers) throws IOException {
  IniSection config=new IniSection();
  config.load(buffer,ENCODING_UTF8,keepers);
  String encoding=config.get(KEY_ENCODING);
  if (!ENCODING_UTF8.equalsIgnoreCase(encoding)) {
    config.clear();
    config.load(buffer,ENCODING_LATIN1,keepers);
  }
  return config;
}
Program: 101416
Project: 101416
Buggy source:
/** 
 * This is default package access for forcing the use of the OpenFileStateManager to manage the creation. Not doing so may result in new instances of OpenFileState being created for no reason, and as a result, if they are released to the OpenFileStateManager by mistake this would result in leakage
 * @param bookMetaData the appropriate metadata for the book
 */
GenBookBackendState(SwordBookMetaData bookMetaData){
  URI path=null;
  try {
    path=SwordUtil.getExpandedDataPath(bookMetaData);
  }
 catch (  BookException e) {
    Reporter.informUser(this,e);
    return;
  }
  bdtFile=new File(path.getPath() + EXTENSION_BDT);
  if (!bdtFile.canRead()) {
    Reporter.informUser(this,new BookException(JSMsg.gettext("String_Node_Str",bdtFile.getAbsolutePath())));
    return;
  }
  try {
    bdtRaf=new RandomAccessFile(bdtFile,FileUtil.MODE_READ);
  }
 catch (  IOException ex) {
    IOUtil.close(bdtRaf);
    log.error("String_Node_Str",ex);
    bdtRaf=null;
  }
}

Fixed version (ground truth):
/** 
 * This is default package access for forcing the use of the OpenFileStateManager to manage the creation. Not doing so may result in new instances of OpenFileState being created for no reason, and as a result, if they are released to the OpenFileStateManager by mistake this would result in leakage
 * @param bookMetaData the appropriate metadata for the book
 */
GenBookBackendState(SwordBookMetaData bookMetaData){
  this.bookMetaData=bookMetaData;
  URI path=null;
  try {
    path=SwordUtil.getExpandedDataPath(bookMetaData);
  }
 catch (  BookException e) {
    Reporter.informUser(this,e);
    return;
  }
  bdtFile=new File(path.getPath() + EXTENSION_BDT);
  if (!bdtFile.canRead()) {
    Reporter.informUser(this,new BookException(JSMsg.gettext("String_Node_Str",bdtFile.getAbsolutePath())));
    return;
  }
  try {
    bdtRaf=new RandomAccessFile(bdtFile,FileUtil.MODE_READ);
  }
 catch (  IOException ex) {
    IOUtil.close(bdtRaf);
    log.error("String_Node_Str",ex);
    bdtRaf=null;
  }
}
Program: 101417
Project: 101417
Buggy source:
public static RawBackendState getRawBackendState(SwordBookMetaData metadata) throws BookException {
  ensureNotShuttingDown();
  RawBackendState state=getInstance(metadata);
  if (state == null) {
    state=new RawBackendState(metadata);
  }
  return state;
}

Fixed version (ground truth):
public static RawBackendState getRawBackendState(SwordBookMetaData metadata) throws BookException {
  ensureNotShuttingDown();
  RawBackendState state=getInstance(metadata);
  if (state == null) {
    LOGGER.trace("String_Node_Str",metadata.getInitials());
    return new RawBackendState(metadata);
  }
  LOGGER.trace("String_Node_Str",metadata.getInitials());
  return state;
}
Program: 101418
Project: 101418
Buggy source:
public static ZVerseBackendState getZVerseBackendState(SwordBookMetaData metadata,BlockType blockType) throws BookException {
  ensureNotShuttingDown();
  ZVerseBackendState state=getInstance(metadata);
  if (state == null) {
    state=new ZVerseBackendState(metadata,blockType);
  }
  return state;
}

Fixed version (ground truth):
public static ZVerseBackendState getZVerseBackendState(SwordBookMetaData metadata,BlockType blockType) throws BookException {
  ensureNotShuttingDown();
  ZVerseBackendState state=getInstance(metadata);
  if (state == null) {
    LOGGER.trace("String_Node_Str",metadata.getInitials());
    return new ZVerseBackendState(metadata,blockType);
  }
  LOGGER.trace("String_Node_Str",metadata.getInitials());
  return state;
}
Program: 101419
Project: 101419
Buggy source:
public static void release(OpenFileState fileState){
  if (fileState == null) {
    return;
  }
  Queue<OpenFileState> queueForMeta=getQueueForMeta(fileState.getBookMetaData());
  boolean offered=queueForMeta.offer(fileState);
  if (!offered) {
    fileState.releaseResources();
  }
}

Fixed version (ground truth):
public static void release(OpenFileState fileState){
  if (fileState == null) {
    return;
  }
  SwordBookMetaData bmd=fileState.getBookMetaData();
  Queue<OpenFileState> queueForMeta=getQueueForMeta(bmd);
  LOGGER.trace("String_Node_Str",bmd.getInitials());
  boolean offered=queueForMeta.offer(fileState);
  if (!offered) {
    LOGGER.trace("String_Node_Str",bmd.getInitials());
    fileState.releaseResources();
  }
}
Program: 101420
Project: 101420
Buggy source:
public static ZLDBackendState getZLDBackendState(SwordBookMetaData metadata) throws BookException {
  ensureNotShuttingDown();
  ZLDBackendState state=getInstance(metadata);
  if (state == null) {
    state=new ZLDBackendState(metadata);
  }
  return state;
}

Fixed version (ground truth):
public static ZLDBackendState getZLDBackendState(SwordBookMetaData metadata) throws BookException {
  ensureNotShuttingDown();
  ZLDBackendState state=getInstance(metadata);
  if (state == null) {
    LOGGER.trace("String_Node_Str",metadata.getInitials());
    return new ZLDBackendState(metadata);
  }
  LOGGER.trace("String_Node_Str",metadata.getInitials());
  return state;
}
Program: 101421
Project: 101421
Buggy source:
public static GenBookBackendState getGenBookBackendState(SwordBookMetaData metadata) throws BookException {
  ensureNotShuttingDown();
  GenBookBackendState state=getInstance(metadata);
  if (state == null) {
    state=new GenBookBackendState(metadata);
  }
  return state;
}

Fixed version (ground truth):
public static GenBookBackendState getGenBookBackendState(SwordBookMetaData metadata) throws BookException {
  ensureNotShuttingDown();
  GenBookBackendState state=getInstance(metadata);
  if (state == null) {
    LOGGER.trace("String_Node_Str",metadata.getInitials());
    return new GenBookBackendState(metadata);
  }
  LOGGER.trace("String_Node_Str",metadata.getInitials());
  return state;
}
Program: 101422
Project: 101422
Buggy source:
@SuppressWarnings("String_Node_Str") private static <T extends OpenFileState>T getInstance(SwordBookMetaData metadata){
  Queue<OpenFileState> availableStates=getQueueForMeta(metadata);
  return (T)availableStates.poll();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private static <T extends OpenFileState>T getInstance(SwordBookMetaData metadata){
  Queue<OpenFileState> availableStates=getQueueForMeta(metadata);
  T queue=(T)availableStates.poll();
  return queue;
}
Program: 101423
Project: 101423
Buggy source:
public static RawFileBackendState getRawFileBackendState(SwordBookMetaData metadata) throws BookException {
  ensureNotShuttingDown();
  RawFileBackendState state=getInstance(metadata);
  if (state == null) {
    state=new RawFileBackendState(metadata);
  }
  return state;
}

Fixed version (ground truth):
public static RawFileBackendState getRawFileBackendState(SwordBookMetaData metadata) throws BookException {
  ensureNotShuttingDown();
  RawFileBackendState state=getInstance(metadata);
  if (state == null) {
    LOGGER.trace("String_Node_Str",metadata.getInitials());
    return new RawFileBackendState(metadata);
  }
  LOGGER.trace("String_Node_Str",metadata.getInitials());
  return state;
}
Program: 101424
Project: 101424
Buggy source:
public static RawLDBackendState getRawLDBackendState(SwordBookMetaData metadata) throws BookException {
  ensureNotShuttingDown();
  RawLDBackendState state=getInstance(metadata);
  if (state == null) {
    state=new RawLDBackendState(metadata);
  }
  return state;
}

Fixed version (ground truth):
public static RawLDBackendState getRawLDBackendState(SwordBookMetaData metadata) throws BookException {
  ensureNotShuttingDown();
  RawLDBackendState state=getInstance(metadata);
  if (state == null) {
    LOGGER.trace("String_Node_Str",metadata.getInitials());
    return new RawLDBackendState(metadata);
  }
  LOGGER.trace("String_Node_Str",metadata.getInitials());
  return state;
}
Program: 101425
Project: 101425
Buggy source:
@Override public final void activate(Lock lock){
  super.activate(lock);
  set=getBackend().readIndex();
  map=new HashMap<String,Key>();
  for (  Key key : set) {
    map.put(key.getName(),key);
  }
  global=new ReadOnlyKeyList(set,false);
  active=true;
}

Fixed version (ground truth):
@Override public final void activate(Lock lock){
  super.activate(lock);
  set=getBackend().readIndex();
  map=new HashMap<String,Key>();
  for (  Key key : set) {
    map.put(key.getOsisRef(),key);
  }
  global=new ReadOnlyKeyList(set,false);
  active=true;
}
Program: 101426
Project: 101426
Buggy source:
@Override public String getOsisID(){
  StringBuilder b=new StringBuilder(100);
  b.append(osisify(getName()));
  for (Key parentKey=this.getParent(); parentKey != null && parentKey.getName().length() > 0; parentKey=parentKey.getParent()) {
    b.insert(0,"String_Node_Str");
    b.insert(0,osisify(parentKey.getName()));
  }
  return b.toString();
}

Fixed version (ground truth):
@Override public String getOsisID(){
  StringBuilder b=new StringBuilder(100);
  b.append(getName());
  for (Key parentKey=this.getParent(); parentKey != null && parentKey.getName().length() > 0; parentKey=parentKey.getParent()) {
    b.insert(0,"String_Node_Str");
    b.insert(0,parentKey.getName());
  }
  return b.toString();
}
Program: 101427
Project: 101427
Buggy source:
public final void close(){
  try {
    if (searcher != null) {
      searcher.close();
    }
  }
 catch (  IOException ex) {
    Reporter.informUser(this,ex);
  }
  try {
    if (directory == null) {
      directory.close();
    }
  }
 catch (  IOException ex) {
    Reporter.informUser(this,ex);
  }
  searcher=null;
  directory=null;
}

Fixed version (ground truth):
public final void close(){
  IOUtil.close(searcher);
  searcher=null;
  IOUtil.close(directory);
  directory=null;
}
Program: 101428
Project: 101428
Buggy source:
/** 
 * Reads a passage as OSIS
 * @param key the given key
 * @param processor a processor for which to do things with
 * @param content a list of content to be appended to (i.e. the OSIS data)
 * @param openFileState the open file state, from which we read things
 * @throws BookException a book exception if we failed to read the book
 */
private Verse readPassageOsis(Key key,RawTextToXmlProcessor processor,final List<Content> content,T openFileState) throws BookException {
  Verse currentVerse=null;
  try {
    final Passage ref=KeyUtil.getPassage(key);
    final Iterator<Key> rit=ref.rangeIterator(RestrictionType.CHAPTER);
    while (rit.hasNext()) {
      VerseRange range=(VerseRange)rit.next();
      processor.preRange(range,content);
      for (      Key verseInRange : range) {
        currentVerse=KeyUtil.getVerse(verseInRange);
        String rawText=readRawContent(openFileState,currentVerse);
        processor.postVerse(verseInRange,content,rawText);
      }
    }
  }
 catch (  IOException e) {
    throwFailedKeyException(key,currentVerse,e);
  }
  return currentVerse;
}

Fixed version (ground truth):
/** 
 * Reads a passage as OSIS
 * @param key           the given key
 * @param processor     a processor for which to do things with
 * @param content       a list of content to be appended to (i.e. the OSIS data)
 * @param openFileState the open file state, from which we read things
 * @throws BookException a book exception if we failed to read the book
 */
private Verse readPassageOsis(Key key,RawTextToXmlProcessor processor,final List<Content> content,T openFileState) throws BookException {
  Verse currentVerse=null;
  final Passage ref=KeyUtil.getPassage(key);
  final Iterator<Key> rit=ref.rangeIterator(RestrictionType.CHAPTER);
  while (rit.hasNext()) {
    VerseRange range=(VerseRange)rit.next();
    processor.preRange(range,content);
    for (    Key verseInRange : range) {
      currentVerse=KeyUtil.getVerse(verseInRange);
      try {
        String rawText=readRawContent(openFileState,currentVerse);
        processor.postVerse(verseInRange,content,rawText);
      }
 catch (      IOException e) {
        LOGGER.debug(e.getMessage(),e);
      }
    }
  }
  return currentVerse;
}
Program: 101429
Project: 101429
Buggy source:
/** 
 * Get the text allotted for the given entry
 * @param key The key to fetch
 * @param processor processor that executes before/after the content is read from disk or another kind of backend
 * @return String The data for the verse in question
 * @throws BookException If the data can not be read.
 */
public List<Content> readToOsis(Key key,RawTextToXmlProcessor processor) throws BookException {
  final List<Content> content=new ArrayList<Content>();
  T openFileState=null;
  try {
    openFileState=initState();
switch (this.bmd.getKeyType()) {
case LIST:
case TREE:
      readNormalOsis(key,processor,content,openFileState);
    break;
case VERSE:
  readPassageOsis(key,processor,content,openFileState);
break;
default :
throw new BookException("String_Node_Str");
}
return content;
}
  finally {
IOUtil.close(openFileState);
}
}

Fixed version (ground truth):
/** 
 * Get the text allotted for the given entry
 * @param key       The key to fetch
 * @param processor processor that executes before/after the content is read fromdisk or another kind of backend
 * @return String The data for the verse in question
 * @throws BookException If the data can not be read.
 */
public List<Content> readToOsis(Key key,RawTextToXmlProcessor processor) throws BookException {
  final List<Content> content=new ArrayList<Content>();
  T openFileState=null;
  try {
    openFileState=initState();
switch (this.bmd.getKeyType()) {
case LIST:
case TREE:
      readNormalOsis(key,processor,content,openFileState);
    break;
case VERSE:
  readPassageOsis(key,processor,content,openFileState);
break;
default :
throw new BookException("String_Node_Str");
}
return content;
}
  finally {
IOUtil.close(openFileState);
}
}
Program: 101430
Project: 101430
Buggy source:
/** 
 * Reads a passage as OSIS
 * @param key the given key
 * @param processor a processor for which to do things with
 * @param content a list of content to be appended to (i.e. the OSIS data)
 * @param openFileState the open file state, from which we read things
 * @throws BookException a book exception if we failed to read the book
 */
private Verse readPassageOsis(Key key,RawTextToXmlProcessor processor,final List<Content> content,T openFileState) throws BookException {
  Verse currentVerse=null;
  try {
    final Passage ref=KeyUtil.getPassage(key);
    final Iterator<Key> rit=ref.rangeIterator(RestrictionType.CHAPTER);
    while (rit.hasNext()) {
      VerseRange range=(VerseRange)rit.next();
      processor.preRange(range,content);
      for (      Key verseInRange : range) {
        currentVerse=KeyUtil.getVerse(verseInRange);
        String rawText=readRawContent(openFileState,currentVerse);
        processor.postVerse(verseInRange,content,rawText);
      }
    }
  }
 catch (  IOException e) {
    throwFailedKeyException(key,currentVerse,e);
  }
  return currentVerse;
}

Fixed version (ground truth):
/** 
 * Reads a passage as OSIS
 * @param key           the given key
 * @param processor     a processor for which to do things with
 * @param content       a list of content to be appended to (i.e. the OSIS data)
 * @param openFileState the open file state, from which we read things
 * @throws BookException a book exception if we failed to read the book
 */
private Verse readPassageOsis(Key key,RawTextToXmlProcessor processor,final List<Content> content,T openFileState) throws BookException {
  Verse currentVerse=null;
  final Passage ref=KeyUtil.getPassage(key);
  final Iterator<Key> rit=ref.rangeIterator(RestrictionType.CHAPTER);
  while (rit.hasNext()) {
    VerseRange range=(VerseRange)rit.next();
    processor.preRange(range,content);
    for (    Key verseInRange : range) {
      currentVerse=KeyUtil.getVerse(verseInRange);
      try {
        String rawText=readRawContent(openFileState,currentVerse);
        processor.postVerse(verseInRange,content,rawText);
      }
 catch (      IOException e) {
        LOGGER.debug(e.getMessage(),e);
      }
    }
  }
  return currentVerse;
}