nus-yam/ex-repair huggingface dataset:
Program: 100721
Project: 100721
Buggy source:
/** 
 * Process attributes
 * @param qName element name
 * @param atts input attributes
 * @param res attributes to write to
 * @throws java.io.IOException if writing to output failed
 */
private void processAttributes(final String qName,final Attributes atts,final AttributesImpl res){
  final int attsLen=atts.getLength();
  for (int i=0; i < attsLen; i++) {
    final String attQName=atts.getQName(i);
    String attValue=getAttributeValue(qName,attQName,atts.getValue(i));
    if (ATTRIBUTE_NAME_CONREF.equals(attQName)) {
      XMLUtils.addOrSetAttribute(res,ATTRIBUTE_NAME_CONREF,replaceHREF(ATTRIBUTE_NAME_CONREF,atts).toString());
    }
 else     if (ATTRIBUTE_NAME_HREF.equals(attQName) || ATTRIBUTE_NAME_COPY_TO.equals(attQName)) {
      if (atts.getValue(ATTRIBUTE_NAME_SCOPE) == null || atts.getValue(ATTRIBUTE_NAME_SCOPE).equals(ATTR_SCOPE_VALUE_LOCAL)) {
        attValue=replaceHREF(attQName,atts).toString();
      }
      XMLUtils.addOrSetAttribute(res,attQName,attValue);
    }
 else {
      XMLUtils.addOrSetAttribute(res,atts.getURI(i),atts.getLocalName(i),attQName,atts.getType(i),attValue);
    }
  }
}

Fixed version (ground truth):
/** 
 * Process attributes
 * @param qName element name
 * @param atts input attributes
 * @param res attributes to write to
 * @throws java.io.IOException if writing to output failed
 */
private void processAttributes(final String qName,final Attributes atts,final AttributesImpl res){
  final int attsLen=atts.getLength();
  for (int i=0; i < attsLen; i++) {
    final String attQName=atts.getQName(i);
    String attValue=getAttributeValue(qName,attQName,atts.getValue(i));
    if (ATTRIBUTE_NAME_CONREF.equals(attQName)) {
      attValue=replaceHREF(ATTRIBUTE_NAME_CONREF,atts).toString();
    }
 else     if (ATTRIBUTE_NAME_HREF.equals(attQName) || ATTRIBUTE_NAME_COPY_TO.equals(attQName)) {
      if (atts.getValue(ATTRIBUTE_NAME_SCOPE) == null || atts.getValue(ATTRIBUTE_NAME_SCOPE).equals(ATTR_SCOPE_VALUE_LOCAL)) {
        attValue=replaceHREF(attQName,atts).toString();
      }
    }
    XMLUtils.addOrSetAttribute(res,atts.getURI(i),atts.getLocalName(i),attQName,atts.getType(i),attValue);
  }
}
Program: 100722
Project: 100722
Buggy source:
/** 
 * Create new URI with a given fragment.
 * @param path URI to set fragment on
 * @param fragment new fragment, {@code null} for no fragment
 * @return new URI instance with given fragment 
 */
public static URI setFragment(final URI path,final String fragment){
  try {
    return new URI(path.getScheme(),path.getUserInfo(),path.getHost(),path.getPort(),path.getPath(),path.getQuery(),fragment);
  }
 catch (  final URISyntaxException e) {
    throw new RuntimeException(e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Create new URI with a given fragment.
 * @param path URI to set fragment on
 * @param fragment new fragment, {@code null} for no fragment
 * @return new URI instance with given fragment 
 */
public static URI setFragment(final URI path,final String fragment){
  try {
    if (path.getPath() != null) {
      return new URI(path.getScheme(),path.getUserInfo(),path.getHost(),path.getPort(),path.getPath(),path.getQuery(),fragment);
    }
 else {
      return new URI(path.getScheme(),path.getSchemeSpecificPart(),fragment);
    }
  }
 catch (  final URISyntaxException e) {
    throw new RuntimeException(e.getMessage(),e);
  }
}
Program: 100723
Project: 100723
Buggy source:
@Test public void testSetFragment() throws URISyntaxException {
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
}

Fixed version (ground truth):
@Test public void testSetFragment() throws URISyntaxException {
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),"String_Node_Str"));
  assertEquals(new URI("String_Node_Str"),URLUtils.setFragment(new URI("String_Node_Str"),null));
}
Program: 100724
Project: 100724
Buggy source:
/** 
 * Get pipe line filters
 * @param fileToParse absolute path to current file being processed
 * @param inFile relative file path
 */
private List<XMLFilter> getProcessingPipe(final File fileToParse,final File inFile){
  final List<XMLFilter> pipe=new ArrayList<XMLFilter>();
  if (genDebugInfo) {
    final DebugFilter debugFilter=new DebugFilter();
    debugFilter.setLogger(logger);
    debugFilter.setInputFile(fileToParse);
    pipe.add(debugFilter);
  }
  if (filterUtils != null) {
    final ProfilingFilter profilingFilter=new ProfilingFilter();
    profilingFilter.setLogger(logger);
    profilingFilter.setFilterUtils(filterUtils);
    pipe.add(profilingFilter);
  }
{
    final ValidationFilter validationFilter=new ValidationFilter();
    validationFilter.setLogger(logger);
    validationFilter.setValidateMap(validateMap);
    pipe.add(validationFilter);
  }
{
    final NormalizeFilter normalizeFilter=new NormalizeFilter();
    normalizeFilter.setLogger(logger);
    normalizeFilter.setCurrentFile(inFile);
    normalizeFilter.setJob(job);
    pipe.add(normalizeFilter);
  }
{
    final ConkeyrefFilter conkeyrefFilter=new ConkeyrefFilter();
    conkeyrefFilter.setLogger(logger);
    conkeyrefFilter.setKeyDefinitions(keys.values());
    conkeyrefFilter.setTempDir(job.tempDir);
    conkeyrefFilter.setCurrentFile(inFile);
    conkeyrefFilter.setDelayConrefUtils(delayConrefUtils);
    pipe.add(conkeyrefFilter);
  }
{
    pipe.add(this);
  }
  return pipe;
}

Fixed version (ground truth):
/** 
 * Get pipe line filters
 * @param fileToParse absolute path to current file being processed
 * @param inFile relative file path
 */
private List<XMLFilter> getProcessingPipe(final File fileToParse,final File inFile){
  final List<XMLFilter> pipe=new ArrayList<XMLFilter>();
  if (genDebugInfo) {
    final DebugFilter debugFilter=new DebugFilter();
    debugFilter.setLogger(logger);
    debugFilter.setInputFile(fileToParse);
    pipe.add(debugFilter);
  }
  if (filterUtils != null) {
    final ProfilingFilter profilingFilter=new ProfilingFilter();
    profilingFilter.setLogger(logger);
    profilingFilter.setFilterUtils(filterUtils);
    pipe.add(profilingFilter);
  }
{
    final ValidationFilter validationFilter=new ValidationFilter();
    validationFilter.setLogger(logger);
    validationFilter.setValidateMap(validateMap);
    validationFilter.setCurrentFile(toURI(inFile));
    validationFilter.setJob(job);
    pipe.add(validationFilter);
  }
{
    final NormalizeFilter normalizeFilter=new NormalizeFilter();
    normalizeFilter.setLogger(logger);
    pipe.add(normalizeFilter);
  }
{
    final ConkeyrefFilter conkeyrefFilter=new ConkeyrefFilter();
    conkeyrefFilter.setLogger(logger);
    conkeyrefFilter.setKeyDefinitions(keys.values());
    conkeyrefFilter.setTempDir(job.tempDir);
    conkeyrefFilter.setCurrentFile(inFile);
    conkeyrefFilter.setDelayConrefUtils(delayConrefUtils);
    pipe.add(conkeyrefFilter);
  }
{
    pipe.add(this);
  }
  return pipe;
}
Program: 100725
Project: 100725
Buggy source:
/** 
 * Sets the grammar pool on the parser. Note that this is a Xerces-specific feature.
 * @param reader
 * @param grammarPool
 */
public void setGrammarPool(final XMLReader reader){
  try {
    reader.setProperty("String_Node_Str",GrammarPoolManager.getGrammarPool());
    logger.info("String_Node_Str");
  }
 catch (  final NoClassDefFoundError e) {
    logger.debug("String_Node_Str");
  }
catch (  final SAXNotRecognizedException e) {
    e.printStackTrace();
    logger.warn("String_Node_Str" + e.getMessage());
  }
catch (  final SAXNotSupportedException e) {
    e.printStackTrace();
    logger.warn("String_Node_Str" + e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Sets the grammar pool on the parser. Note that this is a Xerces-specific feature.
 * @param reader
 */
public void setGrammarPool(final XMLReader reader){
  try {
    reader.setProperty("String_Node_Str",GrammarPoolManager.getGrammarPool());
    logger.info("String_Node_Str");
  }
 catch (  final NoClassDefFoundError e) {
    logger.debug("String_Node_Str");
  }
catch (  final SAXNotRecognizedException e) {
    e.printStackTrace();
    logger.warn("String_Node_Str" + e.getMessage());
  }
catch (  final SAXNotSupportedException e) {
    e.printStackTrace();
    logger.warn("String_Node_Str" + e.getMessage());
  }
}
Program: 100726
Project: 100726
Buggy source:
/** 
 * Write output
 * @param baseDir absolute base directory path
 * @param inFile relative file path
 */
public void write(final File baseDir,final File inFile){
  inputFile=inFile;
  OutputStream out=null;
  try {
    currentFile=new File(baseDir,inputFile.getPath());
    outputFile=new File(tempDir,inputFile.getPath());
    final File outputDir=outputFile.getParentFile();
    if (!outputDir.exists()) {
      outputDir.mkdirs();
    }
    out=new FileOutputStream(outputFile);
    reader.setErrorHandler(new DITAOTXMLErrorHandler(currentFile.getAbsolutePath(),logger));
    final InputSource is=new InputSource(currentFile.toURI().toString());
    if (setSystemid) {
      is.setSystemId(currentFile.toURI().toString());
    }
    final TransformerFactory tf=TransformerFactory.newInstance();
    final Transformer serializer=tf.newTransformer();
    XMLReader xmlSource=reader;
    for (    final XMLFilter f : getProcessingPipe(currentFile,inFile)) {
      f.setParent(xmlSource);
      xmlSource=f;
    }
    xmlSource.setContentHandler(null);
    final Source source=new SAXSource(xmlSource,is);
    final Result result=new StreamResult(out);
    serializer.transform(source,result);
  }
 catch (  final Exception e) {
    e.printStackTrace();
    logger.error(e.getMessage(),e);
  }
 finally {
    if (out != null) {
      try {
        out.close();
      }
 catch (      final Exception e) {
        logger.error(e.getMessage(),e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Write output
 * @param baseDir absolute base directory path
 * @param inFile relative file path
 */
public void write(final File baseDir,final File inFile){
  inputFile=inFile;
  OutputStream out=null;
  try {
    currentFile=new File(baseDir,inputFile.getPath());
    outputFile=new File(tempDir,inputFile.getPath());
    final File outputDir=outputFile.getParentFile();
    if (!outputDir.exists()) {
      outputDir.mkdirs();
    }
    out=new FileOutputStream(outputFile);
    reader.setErrorHandler(new DITAOTXMLErrorHandler(currentFile.getAbsolutePath(),logger));
    final InputSource is=new InputSource(currentFile.toURI().toString());
    if (setSystemid) {
      is.setSystemId(currentFile.toURI().toString());
    }
    final TransformerFactory tf=TransformerFactory.newInstance();
    final Transformer serializer=tf.newTransformer();
    XMLReader xmlSource=reader;
    for (    final XMLFilter f : getProcessingPipe(currentFile,inFile)) {
      f.setParent(xmlSource);
      xmlSource=f;
    }
    xmlSource.setContentHandler(null);
    final Source source=new SAXSource(xmlSource,is);
    final Result result=new StreamResult(out);
    serializer.transform(source,result);
  }
 catch (  final RuntimeException e) {
    throw e;
  }
catch (  final Exception e) {
    e.printStackTrace();
    logger.error(e.getMessage(),e);
  }
 finally {
    if (out != null) {
      try {
        out.close();
      }
 catch (      final Exception e) {
        logger.error(e.getMessage(),e);
      }
    }
  }
}
Program: 100728
Project: 100728
Buggy source:
@Override public void startElement(final String uri,final String localName,final String qName,final Attributes atts) throws SAXException {
  String d=atts.getValue(ATTRIBUTE_NAME_DOMAINS);
  if (d != null) {
    domains.addFirst(StringUtils.getExtProps(d));
  }
 else {
    domains.addFirst(domains.peekFirst());
  }
  AttributesImpl modified=null;
  modified=validateLang(atts,modified);
  validateId(atts);
  modified=validateHref(atts,modified);
  validateKeys(atts);
  validateKeyscope(atts);
  validateAttributeValues(qName,atts);
  validateAttributeGeneralization(atts);
  getContentHandler().startElement(uri,localName,qName,modified != null ? modified : atts);
}

Fixed version (ground truth):
@Override public void startElement(final String uri,final String localName,final String qName,final Attributes atts) throws SAXException {
  String d=atts.getValue(ATTRIBUTE_NAME_DOMAINS);
  if (d != null) {
    domains.addFirst(StringUtils.getExtProps(d));
  }
 else {
    domains.addFirst(domains.peekFirst());
  }
  AttributesImpl modified=null;
  modified=validateLang(atts,modified);
  validateId(atts);
  modified=validateHref(atts,modified);
  modified=processFormatDitamap(atts,modified);
  validateKeys(atts);
  validateKeyscope(atts);
  validateAttributeValues(qName,atts);
  validateAttributeGeneralization(atts);
  getContentHandler().startElement(uri,localName,qName,modified != null ? modified : atts);
}
Program: 100729
Project: 100729
Buggy source:
/** 
 * Sort all the subterms iteratively.
 */
public void sortSubTerms(){
  final int subTermNum=subTerms.size();
  if (subTerms != null && subTermNum > 0) {
    Collections.sort(subTerms);
    for (int i=0; i < subTermNum; i++) {
      final IndexTerm subTerm=subTerms.get(i);
      subTerm.sortSubTerms();
    }
  }
}

Fixed version (ground truth):
/** 
 * Sort all the subterms iteratively.
 */
public void sortSubTerms(){
  final int subTermNum=subTerms.size();
  if (subTerms != null && subTermNum > 0) {
    Collections.sort(subTerms);
    for (    final IndexTerm subTerm : subTerms) {
      subTerm.sortSubTerms();
    }
  }
}
Program: 100730
Project: 100730
Buggy source:
/** 
 * Get Ant executable.
 * @return Ant executable file name
 */
private String getCommandRunner(){
  return (OS_NAME.toLowerCase().indexOf(OS_NAME_WINDOWS) != -1) ? "String_Node_Str" : "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Get Ant executable.
 * @return Ant executable file name
 */
private String getCommandRunner(){
  return (OS_NAME.toLowerCase().contains(OS_NAME_WINDOWS)) ? "String_Node_Str" : "String_Node_Str";
}
Program: 100731
Project: 100731
Buggy source:
/** 
 * Get the current time.
 * @return the current time as a formatted string.
 * @since Ant1.7.1
 */
protected String getTimestamp(){
  final Date date=new Date(System.currentTimeMillis());
  final DateFormat formatter=DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT);
  final String finishTime=formatter.format(date);
  return finishTime;
}

Fixed version (ground truth):
/** 
 * Get the current time.
 * @return the current time as a formatted string.
 * @since Ant1.7.1
 */
protected String getTimestamp(){
  final Date date=new Date(System.currentTimeMillis());
  final DateFormat formatter=DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT);
  return formatter.format(date);
}
Program: 100732
Project: 100732
Buggy source:
/** 
 * Get job configuration from Ant project reference or create new.
 * @param tempDir configuration directory 
 * @param project Ant project
 * @return job configuration
 */
public static Job getJob(final File tempDir,final Project project){
  Job job=(Job)project.getReference(ANT_REFERENCE_JOB);
  if (job != null && job.isStale(tempDir)) {
    project.log("String_Node_Str",Project.MSG_VERBOSE);
    job=null;
  }
  if (job == null) {
    try {
      job=new Job(tempDir);
    }
 catch (    final IOException ioe) {
      throw new BuildException(ioe);
    }
    project.addReference(ANT_REFERENCE_JOB,job);
  }
  return job;
}

Fixed version (ground truth):
/** 
 * Get job configuration from Ant project reference or create new.
 * @param tempDir configuration directory 
 * @param project Ant project
 * @return job configuration
 */
public static Job getJob(final File tempDir,final Project project){
  Job job=project.getReference(ANT_REFERENCE_JOB);
  if (job != null && job.isStale(tempDir)) {
    project.log("String_Node_Str",Project.MSG_VERBOSE);
    job=null;
  }
  if (job == null) {
    try {
      job=new Job(tempDir);
    }
 catch (    final IOException ioe) {
      throw new BuildException(ioe);
    }
    project.addReference(ANT_REFERENCE_JOB,job);
  }
  return job;
}
Program: 100733
Project: 100733
Buggy source:
public void setIncludesfile(final File includesfile) throws IOException {
  final IncludesFile i=new IncludesFile();
  i.setName(includesfile);
  includes.add(i);
}

Fixed version (ground truth):
public void setIncludesfile(final File includesfile){
  final IncludesFile i=new IncludesFile();
  i.setName(includesfile);
  includes.add(i);
}
Program: 100734
Project: 100734
Buggy source:
public void setExcludesfile(final File excludesfile) throws IOException {
  final IncludesFile i=new IncludesFile();
  i.setName(excludesfile);
  excludes.add(i);
}

Fixed version (ground truth):
public void setExcludesfile(final File excludesfile){
  final IncludesFile i=new IncludesFile();
  i.setName(excludesfile);
  excludes.add(i);
}
Program: 100736
Project: 100736
Buggy source:
@Override public void processingInstruction(final String target,final String data) throws SAXException {
  String d=data;
  if (target.equals(PI_WORKDIR_TARGET)) {
    if (workdir != null) {
      try {
        if (OS_NAME.toLowerCase().indexOf(OS_NAME_WINDOWS) == -1) {
          d=workdir.getCanonicalPath();
        }
 else {
          d=UNIX_SEPARATOR + workdir.getCanonicalPath();
        }
      }
 catch (      final IOException e) {
        throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
      }
    }
  }
 else   if (target.equals(PI_WORKDIR_TARGET_URI)) {
    if (workdir != null) {
      d=workdir.toURI().toString();
    }
  }
 else   if (target.equals(PI_PATH2PROJ_TARGET)) {
    if (path2project != null) {
      d=path2project;
    }
  }
 else   if (target.equals(PI_PATH2PROJ_TARGET_URI)) {
    if (path2project != null) {
      d=URLUtils.correct(FileUtils.separatorsToUnix(path2project),true);
    }
  }
  getContentHandler().processingInstruction(target,d);
}

Fixed version (ground truth):
@Override public void processingInstruction(final String target,final String data) throws SAXException {
  String d=data;
  if (target.equals(PI_WORKDIR_TARGET)) {
    if (workdir != null) {
      try {
        if (!OS_NAME.toLowerCase().contains(OS_NAME_WINDOWS)) {
          d=workdir.getCanonicalPath();
        }
 else {
          d=UNIX_SEPARATOR + workdir.getCanonicalPath();
        }
      }
 catch (      final IOException e) {
        throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
      }
    }
  }
 else   if (target.equals(PI_WORKDIR_TARGET_URI)) {
    if (workdir != null) {
      d=workdir.toURI().toString();
    }
  }
 else   if (target.equals(PI_PATH2PROJ_TARGET)) {
    if (path2project != null) {
      d=path2project;
    }
  }
 else   if (target.equals(PI_PATH2PROJ_TARGET_URI)) {
    if (path2project != null) {
      d=URLUtils.correct(FileUtils.separatorsToUnix(path2project),true);
    }
  }
  getContentHandler().processingInstruction(target,d);
}
Program: 100737
Project: 100737
Buggy source:
/** 
 * Init xml reader used for pipeline parsing.
 * @param ditaDir absolute path to DITA-OT directory
 * @param validate whether validate input file
 * @param rootFile absolute path to input file
 * @throws SAXException parsing exception
 * @throws IOException if getting canonical file path fails
 */
private void initXMLReader(final File ditaDir,final boolean validate,final URI rootFile) throws SAXException, IOException {
  reader=StringUtils.getXMLReader();
  reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
  if (validate) {
    reader.setFeature(FEATURE_VALIDATION,true);
    try {
      reader.setFeature(FEATURE_VALIDATION_SCHEMA,true);
    }
 catch (    final SAXNotRecognizedException e) {
    }
  }
 else {
    final String msg=MessageUtils.getInstance().getMessage("String_Node_Str").toString();
    logger.warn(msg);
  }
  if (gramcache) {
    GrammarPoolManager.setGramCache(gramcache);
    final XMLGrammarPool grammarPool=GrammarPoolManager.getGrammarPool();
    try {
      reader.setProperty("String_Node_Str",grammarPool);
      logger.info("String_Node_Str");
    }
 catch (    final Exception e) {
      logger.warn("String_Node_Str" + e.getMessage());
    }
  }
  CatalogUtils.setDitaDir(ditaDir);
  reader.setEntityResolver(CatalogUtils.getCatalogResolver());
}

Fixed version (ground truth):
/** 
 * Init xml reader used for pipeline parsing.
 * @param ditaDir absolute path to DITA-OT directory
 * @param validate whether validate input file
 * @param rootFile absolute path to input file
 * @throws SAXException parsing exception
 * @throws IOException if getting canonical file path fails
 */
private void initXMLReader(final File ditaDir,final boolean validate,final URI rootFile) throws SAXException {
  reader=StringUtils.getXMLReader();
  reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
  if (validate) {
    reader.setFeature(FEATURE_VALIDATION,true);
    try {
      reader.setFeature(FEATURE_VALIDATION_SCHEMA,true);
    }
 catch (    final SAXNotRecognizedException e) {
    }
  }
 else {
    final String msg=MessageUtils.getInstance().getMessage("String_Node_Str").toString();
    logger.warn(msg);
  }
  if (gramcache) {
    GrammarPoolManager.setGramCache(gramcache);
    final XMLGrammarPool grammarPool=GrammarPoolManager.getGrammarPool();
    try {
      reader.setProperty("String_Node_Str",grammarPool);
      logger.info("String_Node_Str");
    }
 catch (    final Exception e) {
      logger.warn("String_Node_Str" + e.getMessage());
    }
  }
  CatalogUtils.setDitaDir(ditaDir);
  reader.setEntityResolver(CatalogUtils.getCatalogResolver());
}
Program: 100738
Project: 100738
Buggy source:
/** 
 * Init xml reader used for pipeline parsing.
 * @param ditaDir absolute path to DITA-OT directory
 * @param validate whether validate input file
 * @param rootFile absolute path to input file
 * @throws SAXException parsing exception
 * @throws IOException if getting canonical file path fails
 */
private void initXMLReader(final File ditaDir,final boolean validate,final File rootFile) throws SAXException, IOException {
  reader=StringUtils.getXMLReader();
  reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
  if (validate) {
    reader.setFeature(FEATURE_VALIDATION,true);
    try {
      reader.setFeature(FEATURE_VALIDATION_SCHEMA,true);
    }
 catch (    final SAXNotRecognizedException e) {
    }
  }
 else {
    final String msg=MessageUtils.getInstance().getMessage("String_Node_Str").toString();
    logger.warn(msg);
  }
  if (gramcache) {
    GrammarPoolManager.setGramCache(gramcache);
    final XMLGrammarPool grammarPool=GrammarPoolManager.getGrammarPool();
    try {
      reader.setProperty("String_Node_Str",grammarPool);
      logger.info("String_Node_Str");
    }
 catch (    final Exception e) {
      logger.warn("String_Node_Str" + e.getMessage());
    }
  }
  CatalogUtils.setDitaDir(ditaDir);
  reader.setEntityResolver(CatalogUtils.getCatalogResolver());
}

Fixed version (ground truth):
/** 
 * Init xml reader used for pipeline parsing.
 * @param ditaDir absolute path to DITA-OT directory
 * @param validate whether validate input file
 * @param rootFile absolute path to input file
 * @throws SAXException parsing exception
 * @throws IOException if getting canonical file path fails
 */
private void initXMLReader(final File ditaDir,final boolean validate,final File rootFile) throws SAXException {
  reader=StringUtils.getXMLReader();
  reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
  if (validate) {
    reader.setFeature(FEATURE_VALIDATION,true);
    try {
      reader.setFeature(FEATURE_VALIDATION_SCHEMA,true);
    }
 catch (    final SAXNotRecognizedException e) {
    }
  }
 else {
    final String msg=MessageUtils.getInstance().getMessage("String_Node_Str").toString();
    logger.warn(msg);
  }
  if (gramcache) {
    GrammarPoolManager.setGramCache(gramcache);
    final XMLGrammarPool grammarPool=GrammarPoolManager.getGrammarPool();
    try {
      reader.setProperty("String_Node_Str",grammarPool);
      logger.info("String_Node_Str");
    }
 catch (    final Exception e) {
      logger.warn("String_Node_Str" + e.getMessage());
    }
  }
  CatalogUtils.setDitaDir(ditaDir);
  reader.setEntityResolver(CatalogUtils.getCatalogResolver());
}
Program: 100739
Project: 100739
Buggy source:
/** 
 * Initialize reusable filters.
 * @throws IOException 
 * @throws SAXException 
 */
private void initFilters() throws SAXException, IOException {
  listFilter=new GenListModuleReader();
  listFilter.setLogger(logger);
  filterUtils=parseFilterFile();
  listFilter.setInputFile(rootFile.getAbsoluteFile());
  listFilter.setInputDir(rootFile.getAbsoluteFile().getParentFile());
  listFilter.setJob(job);
  exportAnchorsFilter=new ExportAnchorsFilter();
  exportAnchorsFilter.setInputFile(rootFile.getAbsoluteFile());
  keydefFilter=new KeydefFilter();
  keydefFilter.setLogger(logger);
  keydefFilter.setInputFile(rootFile.getAbsoluteFile().toURI());
  keydefFilter.setJob(job);
  nullHandler=new DefaultHandler();
}

Fixed version (ground truth):
/** 
 * Initialize reusable filters.
 * @throws IOException 
 * @throws SAXException 
 */
private void initFilters(){
  listFilter=new GenListModuleReader();
  listFilter.setLogger(logger);
  filterUtils=parseFilterFile();
  listFilter.setInputFile(rootFile.getAbsoluteFile());
  listFilter.setInputDir(rootFile.getAbsoluteFile().getParentFile());
  listFilter.setJob(job);
  exportAnchorsFilter=new ExportAnchorsFilter();
  exportAnchorsFilter.setInputFile(rootFile.getAbsoluteFile());
  keydefFilter=new KeydefFilter();
  keydefFilter.setLogger(logger);
  keydefFilter.setInputFile(rootFile.getAbsoluteFile().toURI());
  keydefFilter.setJob(job);
  nullHandler=new DefaultHandler();
}
Program: 100742
Project: 100742
Buggy source:
/** 
 * Write start element.
 * @param elemName element name
 * @param atts attribute
 * @param removeConref whether remeove conref info
 * @throws SAXException if writing element failed
 */
private void putElement(final String elemName,final Attributes atts,final boolean removeConref) throws SAXException {
  try {
    pushcontentWriter.writeStartElement(elemName);
    for (int index=0; index < atts.getLength(); index++) {
      final String name=atts.getQName(index);
      if (!removeConref || !ATTRIBUTE_NAME_CONREF.equals(name) && !ATTRIBUTE_NAME_CONACTION.equals(name)) {
        String value=atts.getValue(index);
        if (ATTRIBUTE_NAME_HREF.equals(name) || ATTRIBUTE_NAME_CONREF.equals(name)) {
          value=replaceURL(value);
        }
        pushcontentWriter.writeAttribute(name,value);
      }
    }
    if (ATTR_CONACTION_VALUE_PUSHREPLACE.equals(pushType) && atts.getValue(ATTRIBUTE_NAME_ID) == null && level == 1) {
      final String fragment=target.getFragment();
      if (fragment == null) {
        logger.error(MessageUtils.getInstance().getMessage("String_Node_Str",target.toString()).toString());
      }
 else {
        final String targetLoc=fragment;
        String id="String_Node_Str";
        if (targetLoc.contains(SLASH)) {
          id=targetLoc.substring(targetLoc.lastIndexOf(SLASH) + 1);
        }
 else {
          id=targetLoc;
        }
        pushcontentWriter.writeAttribute(ATTRIBUTE_NAME_ID,id);
      }
    }
  }
 catch (  final XMLStreamException e) {
    throw new SAXException(e);
  }
}

Fixed version (ground truth):
/** 
 * Write start element.
 * @param elemName element name
 * @param atts attribute
 * @param removeConref whether remeove conref info
 * @throws SAXException if writing element failed
 */
private void putElement(final String elemName,final Attributes atts,final boolean removeConref) throws SAXException {
  try {
    pushcontentWriter.writeStartElement(elemName);
    for (int index=0; index < atts.getLength(); index++) {
      final String name=atts.getQName(index);
      if (!removeConref || !ATTRIBUTE_NAME_CONREF.equals(name) && !ATTRIBUTE_NAME_CONACTION.equals(name)) {
        String value=atts.getValue(index);
        if (ATTRIBUTE_NAME_HREF.equals(name) || ATTRIBUTE_NAME_CONREF.equals(name)) {
          value=replaceURL(value);
        }
        pushcontentWriter.writeAttribute(name,value);
      }
    }
    if (ATTR_CONACTION_VALUE_PUSHREPLACE.equals(pushType) && atts.getValue(ATTRIBUTE_NAME_ID) == null && level == 1) {
      final String fragment=target.getFragment();
      if (fragment == null) {
        logger.error(MessageUtils.getInstance().getMessage("String_Node_Str",target.toString()).toString());
      }
 else {
        String id="String_Node_Str";
        if (fragment.contains(SLASH)) {
          id=fragment.substring(fragment.lastIndexOf(SLASH) + 1);
        }
 else {
          id=fragment;
        }
        pushcontentWriter.writeAttribute(ATTRIBUTE_NAME_ID,id);
      }
    }
  }
 catch (  final XMLStreamException e) {
    throw new SAXException(e);
  }
}
Program: 100743
Project: 100743
Buggy source:
private void genTargets(final IndexTerm indexTerm,final TopicrefElement obj){
  final TopicrefElement topicref=obj;
  final IndexTermTarget target=new IndexTermTarget();
  String targetURI=null;
  final String href=topicref.getHref();
  final StringBuilder buffer=new StringBuilder();
  if (!href.contains(COLON_DOUBLE_SLASH) && !FileUtils.isAbsolutePath(href)) {
    if (mapPath != null && mapPath.length() != 0) {
      buffer.append(mapPath);
      buffer.append(SLASH);
    }
    buffer.append(href);
    targetURI=FileUtils.normalize(buffer.toString()).getPath();
  }
 else {
    targetURI=href;
  }
  if (topicref.getNavTitle() != null) {
    target.setTargetName(topicref.getNavTitle());
  }
 else {
    target.setTargetName(href);
  }
  target.setTargetURI(targetURI);
  assignTarget(indexTerm,target);
}

Fixed version (ground truth):
private void genTargets(final IndexTerm indexTerm,final TopicrefElement obj){
  final IndexTermTarget target=new IndexTermTarget();
  String targetURI=null;
  final String href=obj.getHref();
  final StringBuilder buffer=new StringBuilder();
  if (!href.contains(COLON_DOUBLE_SLASH) && !FileUtils.isAbsolutePath(href)) {
    if (mapPath != null && mapPath.length() != 0) {
      buffer.append(mapPath);
      buffer.append(SLASH);
    }
    buffer.append(href);
    targetURI=FileUtils.normalize(buffer.toString()).getPath();
  }
 else {
    targetURI=href;
  }
  if (obj.getNavTitle() != null) {
    target.setTargetName(obj.getNavTitle());
  }
 else {
    target.setTargetName(href);
  }
  target.setTargetURI(targetURI);
  assignTarget(indexTerm,target);
}
Program: 100744
Project: 100744
Buggy source:
@Override public void endDocument() throws SAXException {
  final int size=indexTermList.size();
  updateIndexTermTargetName();
  for (int i=0; i < size; i++) {
    final IndexTerm indexterm=indexTermList.get(i);
    result.addTerm(indexterm);
  }
}

Fixed version (ground truth):
@Override public void endDocument() throws SAXException {
  final int size=indexTermList.size();
  updateIndexTermTargetName();
  for (  final IndexTerm indexterm : indexTermList) {
    result.addTerm(indexterm);
  }
}
Program: 100745
Project: 100745
Buggy source:
/** 
 * Initialization.
 * @param locale
 */
private void init(final Locale locale){
  Class<?> c=null;
  try {
    c=Class.forName("String_Node_Str");
  }
 catch (  final Exception e) {
    c=Collator.class;
  }
  try {
    final Method m=c.getDeclaredMethod("String_Node_Str",new Class[]{Locale.class});
    collatorInstance=m.invoke(null,new Object[]{locale});
    compareMethod=c.getDeclaredMethod("String_Node_Str",new Class[]{Object.class,Object.class});
  }
 catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Initialization.
 * @param locale
 */
private void init(final Locale locale){
  Class<?> c=null;
  try {
    c=Class.forName("String_Node_Str");
  }
 catch (  final Exception e) {
    c=Collator.class;
  }
  try {
    final Method m=c.getDeclaredMethod("String_Node_Str",new Class[]{Locale.class});
    collatorInstance=m.invoke(null,locale);
    compareMethod=c.getDeclaredMethod("String_Node_Str",new Class[]{Object.class,Object.class});
  }
 catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 100746
Project: 100746
Buggy source:
/** 
 * Comparing method required to compare.
 * @see java.util.Comparator#compare(java.lang.Object,java.lang.Object)
 */
@Override public int compare(final Object source,final Object target){
  try {
    return ((Integer)compareMethod.invoke(collatorInstance,new Object[]{source,target})).intValue();
  }
 catch (  final Exception e) {
    throw new RuntimeException(e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Comparing method required to compare.
 * @see java.util.Comparator#compare(java.lang.Object,java.lang.Object)
 */
@Override public int compare(final Object source,final Object target){
  try {
    return (Integer)compareMethod.invoke(collatorInstance,new Object[]{source,target});
  }
 catch (  final Exception e) {
    throw new RuntimeException(e.getMessage(),e);
  }
}
Program: 100748
Project: 100748
Buggy source:
/** 
 * Check whether a file exists on the local file systmem.
 * @param filename platform path, may contain a hash fragment
 * @return boolean  true if the file exists, false otherwise
 */
public static boolean fileExists(String filename){
  filename=filename.indexOf(SHARP) != -1 ? filename.substring(0,filename.indexOf(SHARP)) : filename;
  return new File(filename).exists();
}

Fixed version (ground truth):
/** 
 * Check whether a file exists on the local file systmem.
 * @param filename platform path, may contain a hash fragment
 * @return boolean  true if the file exists, false otherwise
 */
public static boolean fileExists(String filename){
  filename=filename.contains(SHARP) ? filename.substring(0,filename.indexOf(SHARP)) : filename;
  return new File(filename).exists();
}
Program: 100749
Project: 100749
Buggy source:
/** 
 * Get Base64 encoding content. For ODT transformation
 * @param dirName -The directory name that will be added to the path of the image file.
 * @param fileName -The file name of the image file.
 * @return base64 encoded binary data.
 */
public static String getBASE64(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  final URI imgInputURI=toURI(fileName);
  final File imgInput=imgInputURI.isAbsolute() ? new File(imgInputURI) : new File(dirName,toFile(imgInputURI).getPath());
  final Base64 encoder=new Base64();
  final byte buff[]=new byte[(int)imgInput.length()];
  FileInputStream file=null;
  try {
    file=new FileInputStream(imgInput);
    file.read(buff);
    final String ret=encoder.encodeToString(buff);
    return ret;
  }
 catch (  final FileNotFoundException e) {
    logger.error(MessageUtils.getInstance().getMessage("String_Node_Str").toString());
    logger.error(e.getMessage(),e);
    return null;
  }
catch (  final IOException e) {
    logger.error(MessageUtils.getInstance().getMessage("String_Node_Str").toString());
    logger.error(e.getMessage(),e);
    return null;
  }
 finally {
    if (file != null) {
      try {
        file.close();
      }
 catch (      final IOException ioe) {
        logger.error(ioe.getMessage(),ioe);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Get Base64 encoding content. For ODT transformation
 * @param dirName -The directory name that will be added to the path of the image file.
 * @param fileName -The file name of the image file.
 * @return base64 encoded binary data.
 */
public static String getBASE64(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  final URI imgInputURI=toURI(fileName);
  final File imgInput=imgInputURI.isAbsolute() ? new File(imgInputURI) : new File(dirName,toFile(imgInputURI).getPath());
  final Base64 encoder=new Base64();
  final byte buff[]=new byte[(int)imgInput.length()];
  FileInputStream file=null;
  try {
    file=new FileInputStream(imgInput);
    file.read(buff);
    return encoder.encodeToString(buff);
  }
 catch (  final FileNotFoundException e) {
    logger.error(MessageUtils.getInstance().getMessage("String_Node_Str").toString());
    logger.error(e.getMessage(),e);
    return null;
  }
catch (  final IOException e) {
    logger.error(MessageUtils.getInstance().getMessage("String_Node_Str").toString());
    logger.error(e.getMessage(),e);
    return null;
  }
 finally {
    if (file != null) {
      try {
        file.close();
      }
 catch (      final IOException ioe) {
        logger.error(ioe.getMessage(),ioe);
      }
    }
  }
}
Program: 100750
Project: 100750
Buggy source:
/** 
 * Try to clean an invalid URI.
 * @param path URI to be escaped.
 * @param ascii encode non-ASCII characters to ASCII
 * @return cleaned URI
 */
public static String clean(final String path,final boolean ascii){
  int len=path.length(), ch;
  final StringBuffer buffer=new StringBuffer(len * 3);
  if (len >= 2 && path.charAt(1) == ':') {
    ch=Character.toUpperCase(path.charAt(0));
    if (ch >= 'A' && ch <= 'Z') {
      buffer.append('/');
    }
  }
  int i=0;
  for (; i < len; i++) {
    ch=path.charAt(i);
    if (ch >= 128 && ascii) {
      break;
    }
    if (ch < gNeedEscaping.length && gNeedEscaping[ch]) {
      buffer.append('%');
      buffer.append(gAfterEscaping1[ch]);
      buffer.append(gAfterEscaping2[ch]);
    }
 else {
      buffer.append((char)ch);
    }
  }
  if (i < len && ascii) {
    byte[] bytes;
    byte b;
    try {
      bytes=path.substring(i).getBytes("String_Node_Str");
    }
 catch (    final java.io.UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    len=bytes.length;
    for (i=0; i < len; i++) {
      b=bytes[i];
      if (b < 0) {
        ch=b + 256;
        buffer.append('%');
        buffer.append(gHexChs[ch >> 4]);
        buffer.append(gHexChs[ch & 0xf]);
      }
 else       if (gNeedEscaping[b]) {
        buffer.append('%');
        buffer.append(gAfterEscaping1[b]);
        buffer.append(gAfterEscaping2[b]);
      }
 else {
        buffer.append((char)b);
      }
    }
  }
  return buffer.toString();
}

Fixed version (ground truth):
/** 
 * Try to clean an invalid URI.
 * @param path URI to be escaped.
 * @param ascii encode non-ASCII characters to ASCII
 * @return cleaned URI
 */
public static String clean(final String path,final boolean ascii){
  int len=path.length(), ch;
  final StringBuilder buffer=new StringBuilder(len * 3);
  if (len >= 2 && path.charAt(1) == ':') {
    ch=Character.toUpperCase(path.charAt(0));
    if (ch >= 'A' && ch <= 'Z') {
      buffer.append('/');
    }
  }
  int i=0;
  for (; i < len; i++) {
    ch=path.charAt(i);
    if (ch >= 128 && ascii) {
      break;
    }
    if (ch < gNeedEscaping.length && gNeedEscaping[ch]) {
      buffer.append('%');
      buffer.append(gAfterEscaping1[ch]);
      buffer.append(gAfterEscaping2[ch]);
    }
 else {
      buffer.append((char)ch);
    }
  }
  if (i < len && ascii) {
    byte[] bytes;
    byte b;
    try {
      bytes=path.substring(i).getBytes("String_Node_Str");
    }
 catch (    final java.io.UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    len=bytes.length;
    for (i=0; i < len; i++) {
      b=bytes[i];
      if (b < 0) {
        ch=b + 256;
        buffer.append('%');
        buffer.append(gHexChs[ch >> 4]);
        buffer.append(gHexChs[ch & 0xf]);
      }
 else       if (gNeedEscaping[b]) {
        buffer.append('%');
        buffer.append(gAfterEscaping1[b]);
        buffer.append(gAfterEscaping2[b]);
      }
 else {
        buffer.append((char)b);
      }
    }
  }
  return buffer.toString();
}
Program: 100751
Project: 100751
Buggy source:
/** 
 * Get relative path to base path. <p>For   {@code foo/bar/baz.txt} return {@code ../../}</p>
 * @param relativePath relative URI
 * @return relative URI to base path, {@code null} if reference path was a single file
 */
public static URI getRelativePath(final URI relativePath){
  final StringTokenizer tokenizer=new StringTokenizer(relativePath.toString(),URI_SEPARATOR);
  final StringBuffer buffer=new StringBuffer();
  if (tokenizer.countTokens() == 1) {
    return null;
  }
 else {
    while (tokenizer.countTokens() > 1) {
      tokenizer.nextToken();
      buffer.append("String_Node_Str");
      buffer.append(URI_SEPARATOR);
    }
    return toURI(buffer.toString());
  }
}

Fixed version (ground truth):
/** 
 * Get relative path to base path. <p>For   {@code foo/bar/baz.txt} return {@code ../../}</p>
 * @param relativePath relative URI
 * @return relative URI to base path, {@code null} if reference path was a single file
 */
public static URI getRelativePath(final URI relativePath){
  final StringTokenizer tokenizer=new StringTokenizer(relativePath.toString(),URI_SEPARATOR);
  final StringBuilder buffer=new StringBuilder();
  if (tokenizer.countTokens() == 1) {
    return null;
  }
 else {
    while (tokenizer.countTokens() > 1) {
      tokenizer.nextToken();
      buffer.append("String_Node_Str");
      buffer.append(URI_SEPARATOR);
    }
    return toURI(buffer.toString());
  }
}
Program: 100752
Project: 100752
Buggy source:
/** 
 * get the document node of a topic file.
 * @param absolutePathToFile topic file
 * @return element.
 */
private Element getTopicDoc(final String absolutePathToFile){
  final DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
  DocumentBuilder builder;
  try {
    builder=factory.newDocumentBuilder();
    final Document doc=builder.parse(absolutePathToFile);
    final Element root=doc.getDocumentElement();
    return root;
  }
 catch (  final ParserConfigurationException e) {
    e.printStackTrace();
  }
catch (  final SAXException e) {
    e.printStackTrace();
  }
catch (  final IOException e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * get the document node of a topic file.
 * @param absolutePathToFile topic file
 * @return element.
 */
private Element getTopicDoc(final String absolutePathToFile){
  final DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
  DocumentBuilder builder;
  try {
    builder=factory.newDocumentBuilder();
    final Document doc=builder.parse(absolutePathToFile);
    return doc.getDocumentElement();
  }
 catch (  final ParserConfigurationException e) {
    e.printStackTrace();
  }
catch (  final SAXException e) {
    e.printStackTrace();
  }
catch (  final IOException e) {
    e.printStackTrace();
  }
  return null;
}
Program: 100753
Project: 100753
Buggy source:
@Override public void write(final File filename){
  if (filename == null || !filename.exists()) {
    return;
  }
  curMatchTopic=topicSet.contains(SHARP) ? SHARP : null;
  topicIdStack=new ArrayDeque<String>();
  final File inputFile=filename;
  final File outputFile=new File(filename.getPath() + FILE_EXTENSION_TEMP);
  FileOutputStream fileOutput=null;
  try {
    fileOutput=new FileOutputStream(outputFile);
    output=new OutputStreamWriter(fileOutput,UTF8);
    reader.setErrorHandler(new DITAOTXMLErrorHandler(filename.getPath(),logger));
    reader.parse(inputFile.toURI().toString());
  }
 catch (  final Exception e) {
    logger.error(e.getMessage(),e);
  }
 finally {
    try {
      if (fileOutput != null) {
        fileOutput.close();
      }
    }
 catch (    final Exception e) {
      logger.error(e.getMessage(),e);
    }
    try {
      if (output != null) {
        output.close();
      }
    }
 catch (    final Exception e) {
      logger.error(e.getMessage(),e);
    }
  }
  try {
    FileUtils.moveFile(outputFile,inputFile);
  }
 catch (  final Exception e) {
    logger.error("String_Node_Str" + inputFile + "String_Node_Str"+ e.getMessage());
  }
}

Fixed version (ground truth):
@Override public void write(final File filename){
  if (filename == null || !filename.exists()) {
    return;
  }
  curMatchTopic=topicSet.contains(SHARP) ? SHARP : null;
  topicIdStack=new ArrayDeque<String>();
  final File outputFile=new File(filename.getPath() + FILE_EXTENSION_TEMP);
  FileOutputStream fileOutput=null;
  try {
    fileOutput=new FileOutputStream(outputFile);
    output=new OutputStreamWriter(fileOutput,UTF8);
    reader.setErrorHandler(new DITAOTXMLErrorHandler(filename.getPath(),logger));
    reader.parse(filename.toURI().toString());
  }
 catch (  final Exception e) {
    logger.error(e.getMessage(),e);
  }
 finally {
    try {
      if (fileOutput != null) {
        fileOutput.close();
      }
    }
 catch (    final Exception e) {
      logger.error(e.getMessage(),e);
    }
    try {
      if (output != null) {
        output.close();
      }
    }
 catch (    final Exception e) {
      logger.error(e.getMessage(),e);
    }
  }
  try {
    FileUtils.moveFile(outputFile,filename);
  }
 catch (  final Exception e) {
    logger.error("String_Node_Str" + filename + "String_Node_Str"+ e.getMessage());
  }
}
Program: 100756
Project: 100756
Buggy source:
/** 
 * Update href URI.
 * @param href href URI
 * @return updated href URI
 */
private URI updateHref(final URI href){
  final URI tempDirUri=tempDir.toURI();
  final URI filePath=tempDirUri.resolve(toURI(inputFile));
  final URI keyValue=tempDirUri.resolve(href);
  final URI updatedHref=URLUtils.getRelativePath(filePath,keyValue);
  return updatedHref;
}

Fixed version (ground truth):
/** 
 * Update href URI.
 * @param href href URI
 * @return updated href URI
 */
private URI updateHref(final URI href){
  final URI tempDirUri=tempDir.toURI();
  final URI filePath=tempDirUri.resolve(toURI(inputFile));
  final URI keyValue=tempDirUri.resolve(href);
  return URLUtils.getRelativePath(filePath,keyValue);
}