nus-yam/ex-repair huggingface dataset:
Program: 100802
Project: 100802
Buggy source:
/** 
 * execution point of MoveLinksModule.
 * @param input input parameters and resources
 * @return always {@code null}
 * @throws DITAOTException if process fails
 */
public AbstractPipelineOutput execute(final AbstractPipelineInput input) throws DITAOTException {
  if (logger == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  final File maplinksFile=new File(input.getAttribute(ANT_INVOKER_PARAM_MAPLINKS));
  final MapLinksReader indexReader=new MapLinksReader();
  indexReader.setLogger(logger);
  indexReader.setMatch(new StringBuffer(ELEMENT_NAME_MAPLINKS).append(SLASH).append(TOPIC_LINKPOOL.localName).append(SLASH).append(TOPIC_LINKLIST.localName).toString());
  indexReader.read(maplinksFile.getAbsolutePath());
  final Map<String,Map<String,String>> mapSet=(Map<String,Map<String,String>>)indexReader.getContent().getCollection();
  final DitaLinksWriter indexInserter=new DitaLinksWriter();
  indexInserter.setLogger(logger);
  for (  final Map.Entry<String,Map<String,String>> entry : mapSet.entrySet()) {
    logger.logInfo("String_Node_Str" + entry.getKey());
    final ContentImpl content=new ContentImpl();
    content.setValue(entry.getValue());
    indexInserter.setContent(content);
    indexInserter.write(entry.getKey());
  }
  return null;
}

Fixed version (ground truth):
/** 
 * execution point of MoveLinksModule.
 * @param input input parameters and resources
 * @return always {@code null}
 * @throws DITAOTException if process fails
 */
public AbstractPipelineOutput execute(final AbstractPipelineInput input) throws DITAOTException {
  if (logger == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  final File maplinksFile=new File(input.getAttribute(ANT_INVOKER_PARAM_MAPLINKS));
  final MapLinksReader indexReader=new MapLinksReader();
  indexReader.setLogger(logger);
  indexReader.setMatch(new StringBuffer(ELEMENT_NAME_MAPLINKS).append(SLASH).append(TOPIC_LINKPOOL.localName).append(SLASH).append(TOPIC_LINKLIST.localName).toString());
  indexReader.read(maplinksFile.getAbsolutePath());
  final Map<String,Map<String,String>> mapSet=indexReader.getMapping();
  final DitaLinksWriter indexInserter=new DitaLinksWriter();
  indexInserter.setLogger(logger);
  for (  final Map.Entry<String,Map<String,String>> entry : mapSet.entrySet()) {
    logger.logInfo("String_Node_Str" + entry.getKey());
    final ContentImpl content=new ContentImpl();
    content.setValue(entry.getValue());
    indexInserter.setContent(content);
    indexInserter.write(entry.getKey());
  }
  return null;
}
Program: 100805
Project: 100805
Buggy source:
/** 
 * Rewrite local non-DITA href value.
 * @param attValue href attribute value
 * @return rewritten href value
 */
private String handleLocalHref(final String attValue){
  return FileUtils.resolveTopic(new File(filePath).getParent(),attValue);
}

Fixed version (ground truth):
/** 
 * Rewrite local non-DITA href value. <p>TODO: return type should be   {@link java.util.URI}.</p>
 * @param attValue href attribute value
 * @return rewritten href value
 */
private String handleLocalHref(final String attValue){
  return FileUtils.resolveTopic(new File(filePath).getParent(),attValue);
}
Program: 100807
Project: 100807
Buggy source:
/** 
 * Default Constructor.
 */
public MergeMapParser(){
  processStack=new Stack<String>();
  processLevel=0;
  util=new MergeUtils();
  topicParser=new MergeTopicParser(util);
  topicParser.setLogger(logger);
  topicBuffer=new ByteArrayOutputStream();
  try {
    reader=StringUtils.getXMLReader();
    reader.setContentHandler(this);
    reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
    final TransformerFactory tf=TransformerFactory.newInstance();
    if (!tf.getFeature(SAXTransformerFactory.FEATURE)) {
      throw new RuntimeException("String_Node_Str");
    }
    stf=(SAXTransformerFactory)tf;
    final TransformerHandler s=stf.newTransformerHandler();
    s.getTransformer().setOutputProperty(OMIT_XML_DECLARATION,"String_Node_Str");
    s.setResult(new StreamResult(topicBuffer));
    topicParser.setContentHandler(s);
  }
 catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Default Constructor.
 */
public MergeMapParser(){
  processStack=new Stack<String>();
  processLevel=0;
  util=new MergeUtils();
  topicParser=new MergeTopicParser(util);
  topicBuffer=new ByteArrayOutputStream();
  try {
    reader=StringUtils.getXMLReader();
    reader.setContentHandler(this);
    reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
    final TransformerFactory tf=TransformerFactory.newInstance();
    if (!tf.getFeature(SAXTransformerFactory.FEATURE)) {
      throw new RuntimeException("String_Node_Str");
    }
    stf=(SAXTransformerFactory)tf;
    final TransformerHandler s=stf.newTransformerHandler();
    s.getTransformer().setOutputProperty(OMIT_XML_DECLARATION,"String_Node_Str");
    s.setResult(new StreamResult(topicBuffer));
    topicParser.setContentHandler(s);
  }
 catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 100809
Project: 100809
Buggy source:
public final void setLogger(final DITAOTLogger logger){
  this.logger=logger;
}

Fixed version (ground truth):
public final void setLogger(final DITAOTLogger logger){
  this.logger=logger;
  topicParser.setLogger(logger);
}
Program: 100810
Project: 100810
Buggy source:
/** 
 * Default Constructor.
 */
public MergeMapParser(){
  processStack=new Stack<String>();
  processLevel=0;
  util=new MergeUtils();
  topicParser=new MergeTopicParser(util);
  topicParser.setLogger(logger);
  topicBuffer=new ByteArrayOutputStream();
  try {
    reader=StringUtils.getXMLReader();
    reader.setContentHandler(this);
    reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
    final TransformerFactory tf=TransformerFactory.newInstance();
    if (!tf.getFeature(SAXTransformerFactory.FEATURE)) {
      throw new RuntimeException("String_Node_Str");
    }
    stf=(SAXTransformerFactory)tf;
    final TransformerHandler s=stf.newTransformerHandler();
    s.getTransformer().setOutputProperty(OMIT_XML_DECLARATION,"String_Node_Str");
    s.setResult(new StreamResult(topicBuffer));
    topicParser.setContentHandler(s);
  }
 catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Default Constructor.
 */
public MergeMapParser(){
  processStack=new Stack<String>();
  processLevel=0;
  util=new MergeUtils();
  topicParser=new MergeTopicParser(util);
  topicBuffer=new ByteArrayOutputStream();
  try {
    reader=StringUtils.getXMLReader();
    reader.setContentHandler(this);
    reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
    final TransformerFactory tf=TransformerFactory.newInstance();
    if (!tf.getFeature(SAXTransformerFactory.FEATURE)) {
      throw new RuntimeException("String_Node_Str");
    }
    stf=(SAXTransformerFactory)tf;
    final TransformerHandler s=stf.newTransformerHandler();
    s.getTransformer().setOutputProperty(OMIT_XML_DECLARATION,"String_Node_Str");
    s.setResult(new StreamResult(topicBuffer));
    topicParser.setContentHandler(s);
  }
 catch (  final Exception e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 100812
Project: 100812
Buggy source:
public final void setLogger(final DITAOTLogger logger){
  this.logger=logger;
}

Fixed version (ground truth):
public final void setLogger(final DITAOTLogger logger){
  this.logger=logger;
  topicParser.setLogger(logger);
}
Program: 100813
Project: 100813
Buggy source:
@Override public void ignorableWhitespace(final char[] ch,final int start,final int length) throws SAXException {
  if (!exclude) {
    try {
      getContentHandler().ignorableWhitespace(ch,start,length);
    }
 catch (    final Exception e) {
      logger.logException(e);
    }
  }
}

Fixed version (ground truth):
@Override public void ignorableWhitespace(final char[] ch,final int start,final int length) throws SAXException {
  if (!exclude) {
    try {
      getContentHandler().characters(ch,start,length);
    }
 catch (    final Exception e) {
      logger.logException(e);
    }
  }
}
Program: 100816
Project: 100816
Buggy source:
/** 
 * Write keydef into keydef.xml.
 * @param keyName key name.
 * @param result keydef.
 */
private void writeKeyDef(final KeyDef keyDef){
  try {
    keydef.writeStartElement("String_Node_Str");
    keydef.writeAttribute("String_Node_Str",keyDef.keys);
    keydef.writeAttribute("String_Node_Str",keyDef.href);
    if (keyDef.source != null) {
      keydef.writeAttribute("String_Node_Str",keyDef.source);
    }
    keydef.writeEndElement();
  }
 catch (  final SAXException e) {
    logger.logException(e);
  }
}

Fixed version (ground truth):
/** 
 * Write keydef into keydef.xml.
 * @param keyName key name.
 * @param result keydef.
 */
private void writeKeyDef(final KeyDef keyDef){
  try {
    keydef.writeStartElement("String_Node_Str");
    keydef.writeAttribute("String_Node_Str",keyDef.keys);
    if (keyDef.href != null) {
      keydef.writeAttribute("String_Node_Str",keyDef.href);
    }
    if (keyDef.source != null) {
      keydef.writeAttribute("String_Node_Str",keyDef.source);
    }
    keydef.writeEndElement();
  }
 catch (  final SAXException e) {
    logger.logException(e);
  }
}
Program: 100818
Project: 100818
Buggy source:
/** 
 * Add or set attribute. Convenience method for   {@link #addOrSetAttribute(AttributesImpl,String,String,String,String,String)}.
 * @param atts attributes
 * @param att attribute node
 */
public static void addOrSetAttribute(final AttributesImpl atts,final Node att){
  if (att.getNodeType() != Node.ATTRIBUTE_NODE) {
    throw new IllegalArgumentException();
  }
  final Attr a=(Attr)att;
  addOrSetAttribute(atts,a.getNamespaceURI() != null ? a.getNamespaceURI() : NULL_NS_URI,a.getLocalName() != null ? a.getLocalName() : "String_Node_Str",a.getName() != null ? a.getName() : "String_Node_Str",a.isId() ? "String_Node_Str" : "String_Node_Str",a.getValue());
}

Fixed version (ground truth):
/** 
 * Add or set attribute. Convenience method for   {@link #addOrSetAttribute(AttributesImpl,String,String,String,String,String)}.
 * @param atts attributes
 * @param att attribute node
 */
public static void addOrSetAttribute(final AttributesImpl atts,final Node att){
  if (att.getNodeType() != Node.ATTRIBUTE_NODE) {
    throw new IllegalArgumentException();
  }
  final Attr a=(Attr)att;
  addOrSetAttribute(atts,a.getNamespaceURI() != null ? a.getNamespaceURI() : NULL_NS_URI,a.getLocalName() != null ? a.getLocalName() : (a.getName() != null ? a.getName() : "String_Node_Str"),a.getName() != null ? a.getName() : "String_Node_Str",a.isId() ? "String_Node_Str" : "String_Node_Str",a.getValue());
}
Program: 100819
Project: 100819
Buggy source:
/** 
 * Add or set attribute. Convenience method for   {@link #addOrSetAttribute(AttributesImpl,String,String,String,String,String)}.
 * @param atts attributes
 * @param att attribute node
 */
public static void addOrSetAttribute(final AttributesImpl atts,final Node att){
  if (att.getNodeType() != Node.ATTRIBUTE_NODE) {
    throw new IllegalArgumentException();
  }
  final Attr a=(Attr)att;
  addOrSetAttribute(atts,a.getNamespaceURI() != null ? a.getNamespaceURI() : NULL_NS_URI,a.getLocalName() != null ? a.getLocalName() : (a.getName() != null ? a.getName() : "String_Node_Str"),a.getName() != null ? a.getName() : "String_Node_Str",a.isId() ? "String_Node_Str" : "String_Node_Str",a.getValue());
}

Fixed version (ground truth):
/** 
 * Add or set attribute. Convenience method for   {@link #addOrSetAttribute(AttributesImpl,String,String,String,String,String)}.
 * @param atts attributes
 * @param att attribute node
 */
public static void addOrSetAttribute(final AttributesImpl atts,final Node att){
  if (att.getNodeType() != Node.ATTRIBUTE_NODE) {
    throw new IllegalArgumentException();
  }
  final Attr a=(Attr)att;
  String localName=a.getLocalName();
  if (localName == null) {
    localName=a.getName();
    final int i=localName.indexOf(':');
    if (i != -1) {
      localName=localName.substring(i + 1);
    }
  }
  addOrSetAttribute(atts,a.getNamespaceURI() != null ? a.getNamespaceURI() : NULL_NS_URI,localName,a.getName() != null ? a.getName() : localName,a.isId() ? "String_Node_Str" : "String_Node_Str",a.getValue());
}
Program: 100825
Project: 100825
Buggy source:
@Test public void testread(){
  final File path=new File(resourceDir,"String_Node_Str" + File.separator);
  DitaURIResolverFactory.setPath(path.getAbsolutePath());
  final ListReader listreader=new ListReader();
  listreader.read(null);
  final String userinputfile="String_Node_Str" + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str";
  assertEquals(userinputfile,listreader.getContent().getValue().toString());
  final String userinputmap="String_Node_Str";
  assertEquals(userinputmap,listreader.getInputMap());
  final String subjectschemelist="String_Node_Str";
  assertEquals(subjectschemelist,listreader.getSchemeSet().toString());
}

Fixed version (ground truth):
@Test public void testread(){
  final File path=new File(resourceDir,"String_Node_Str" + File.separator);
  DitaURIResolverFactory.setPath(path.getAbsolutePath());
  final ListReader listreader=new ListReader();
  listreader.read(null);
  final String userinputfile="String_Node_Str" + UNIX_SEPARATOR + "String_Node_Str"+ UNIX_SEPARATOR+ "String_Node_Str"+ UNIX_SEPARATOR+ "String_Node_Str"+ UNIX_SEPARATOR+ "String_Node_Str"+ UNIX_SEPARATOR+ "String_Node_Str"+ UNIX_SEPARATOR+ "String_Node_Str"+ UNIX_SEPARATOR+ "String_Node_Str"+ UNIX_SEPARATOR+ "String_Node_Str";
  assertEquals(userinputfile,listreader.getContent().getValue().toString());
  final String userinputmap="String_Node_Str";
  assertEquals(userinputmap,listreader.getInputMap());
  final String subjectschemelist="String_Node_Str";
  assertEquals(subjectschemelist,listreader.getSchemeSet().toString());
}
Program: 100826
Project: 100826
Buggy source:
/** 
 * Get the image height(ODT Transform).
 * @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 int -The height of the picture in pixels.
 */
public static int getHeightODT(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  final File imgInput=new File(getImageOutPutPath(fileName));
  try {
    final BufferedImage img=ImageIO.read(imgInput);
    return img.getHeight();
  }
 catch (  final Exception e) {
    final Properties prop=new Properties();
    prop.put("String_Node_Str",dirName + File.separatorChar + fileName);
    logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    logger.logException(e);
    return -1;
  }
}

Fixed version (ground truth):
/** 
 * Get the image height(ODT Transform).
 * @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 int -The height of the picture in pixels.
 */
public static int getHeightODT(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  File imgInput=new File(dirName + File.separatorChar + fileName);
  if (checkDirName(dirName))   imgInput=new File(getImageOutPutPath(fileName));
  try {
    final BufferedImage img=ImageIO.read(imgInput);
    return img.getHeight();
  }
 catch (  final Exception e) {
    final Properties prop=new Properties();
    prop.put("String_Node_Str",dirName + File.separatorChar + fileName);
    logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    logger.logException(e);
    return -1;
  }
}
Program: 100827
Project: 100827
Buggy source:
/** 
 * Get the image binary data, with hexical output. For RTF 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 java.lang.String -The Hexical binary of image data converted to String.
 */
public static String getBinData(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  final File imgInput=new File(getImageOutPutPath(fileName));
  FileInputStream binInput=null;
  int bin;
  try {
    String binStr=null;
    final StringBuffer ret=new StringBuffer(INT_16 * INT_1024);
    binInput=new FileInputStream(imgInput);
    bin=binInput.read();
    while (bin != -1) {
      binStr=Integer.toHexString(bin);
      if (binStr.length() < 2) {
        ret.append("String_Node_Str");
      }
      ret.append(binStr);
      bin=binInput.read();
    }
    return ret.toString();
  }
 catch (  final Exception e) {
    logger.logError(MessageUtils.getMessage("String_Node_Str").toString());
    logger.logException(e);
    return null;
  }
 finally {
    try {
      binInput.close();
    }
 catch (    final IOException ioe) {
      logger.logException(ioe);
    }
  }
}

Fixed version (ground truth):
/** 
 * Get the image binary data, with hexical output. For RTF 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 java.lang.String -The Hexical binary of image data converted to String.
 */
public static String getBinData(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  File imgInput=new File(dirName + File.separatorChar + fileName);
  if (checkDirName(dirName))   imgInput=new File(getImageOutPutPath(fileName));
  FileInputStream binInput=null;
  int bin;
  try {
    String binStr=null;
    final StringBuffer ret=new StringBuffer(INT_16 * INT_1024);
    binInput=new FileInputStream(imgInput);
    bin=binInput.read();
    while (bin != -1) {
      binStr=Integer.toHexString(bin);
      if (binStr.length() < 2) {
        ret.append("String_Node_Str");
      }
      ret.append(binStr);
      bin=binInput.read();
    }
    return ret.toString();
  }
 catch (  final Exception e) {
    logger.logError(MessageUtils.getMessage("String_Node_Str").toString());
    logger.logException(e);
    return null;
  }
 finally {
    try {
      binInput.close();
    }
 catch (    final IOException ioe) {
      logger.logException(ioe);
    }
  }
}
Program: 100828
Project: 100828
Buggy source:
/** 
 * Get the image height.
 * @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 int -The height of the picture in pixels.
 */
public static int getHeight(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  final File imgInput=new File(getImageOutPutPath(fileName));
  try {
    final BufferedImage img=ImageIO.read(imgInput);
    return img.getHeight();
  }
 catch (  final Exception e) {
    final Properties prop=new Properties();
    prop.put("String_Node_Str",dirName + File.separatorChar + fileName);
    logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    logger.logException(e);
    return -1;
  }
}

Fixed version (ground truth):
/** 
 * Get the image height.
 * @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 int -The height of the picture in pixels.
 */
public static int getHeight(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  File imgInput=new File(dirName + File.separatorChar + fileName);
  if (checkDirName(dirName))   imgInput=new File(getImageOutPutPath(fileName));
  try {
    final BufferedImage img=ImageIO.read(imgInput);
    return img.getHeight();
  }
 catch (  final Exception e) {
    final Properties prop=new Properties();
    prop.put("String_Node_Str",dirName + File.separatorChar + fileName);
    logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    logger.logException(e);
    return -1;
  }
}
Program: 100829
Project: 100829
Buggy source:
/** 
 * Get the image width(ODT Transform).
 * @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 int -The width of the picture in pixels.
 */
public static int getWidthODT(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  final File imgInput=new File(getImageOutPutPath(fileName));
  try {
    final BufferedImage img=ImageIO.read(imgInput);
    return img.getWidth();
  }
 catch (  final Exception e) {
    final Properties prop=new Properties();
    prop.put("String_Node_Str",dirName + File.separatorChar + fileName);
    logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    logger.logException(e);
    return -1;
  }
}

Fixed version (ground truth):
/** 
 * Get the image width(ODT Transform).
 * @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 int -The width of the picture in pixels.
 */
public static int getWidthODT(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  File imgInput=new File(dirName + File.separatorChar + fileName);
  if (checkDirName(dirName))   imgInput=new File(getImageOutPutPath(fileName));
  try {
    final BufferedImage img=ImageIO.read(imgInput);
    return img.getWidth();
  }
 catch (  final Exception e) {
    final Properties prop=new Properties();
    prop.put("String_Node_Str",dirName + File.separatorChar + fileName);
    logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    logger.logException(e);
    return -1;
  }
}
Program: 100830
Project: 100830
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 File imgInput=new File(getImageOutPutPath(fileName));
  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.logError(MessageUtils.getMessage("String_Node_Str").toString());
    logger.logException(e);
    return null;
  }
catch (  final IOException e) {
    logger.logError(MessageUtils.getMessage("String_Node_Str").toString());
    logger.logException(e);
    return null;
  }
 finally {
    try {
      file.close();
    }
 catch (    final IOException ioe) {
      logger.logException(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();
  File imgInput=new File(dirName + File.separatorChar + fileName);
  if (checkDirName(dirName))   imgInput=new File(getImageOutPutPath(fileName));
  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.logError(MessageUtils.getMessage("String_Node_Str").toString());
    logger.logException(e);
    return null;
  }
catch (  final IOException e) {
    logger.logError(MessageUtils.getMessage("String_Node_Str").toString());
    logger.logException(e);
    return null;
  }
 finally {
    try {
      file.close();
    }
 catch (    final IOException ioe) {
      logger.logException(ioe);
    }
  }
}
Program: 100831
Project: 100831
Buggy source:
/** 
 * Get the image width.
 * @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 int -The width of the picture in pixels.
 */
public static int getWidth(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  final File imgInput=new File(getImageOutPutPath(fileName));
  try {
    final BufferedImage img=ImageIO.read(imgInput);
    return img.getWidth();
  }
 catch (  final Exception e) {
    final Properties prop=new Properties();
    prop.put("String_Node_Str",dirName + File.separatorChar + fileName);
    logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    logger.logException(e);
    return -1;
  }
}

Fixed version (ground truth):
/** 
 * Get the image width.
 * @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 int -The width of the picture in pixels.
 */
public static int getWidth(final String dirName,final String fileName){
  final DITAOTJavaLogger logger=new DITAOTJavaLogger();
  File imgInput=new File(dirName + File.separatorChar + fileName);
  if (checkDirName(dirName))   imgInput=new File(getImageOutPutPath(fileName));
  try {
    final BufferedImage img=ImageIO.read(imgInput);
    return img.getWidth();
  }
 catch (  final Exception e) {
    final Properties prop=new Properties();
    prop.put("String_Node_Str",dirName + File.separatorChar + fileName);
    logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    logger.logException(e);
    return -1;
  }
}
Program: 100832
Project: 100832
Buggy source:
/** 
 * Read temporary configuration files.
 * @throws IOException if reading configuration files failed
 * @throws IllegalStateException if configuration files are missing
 */
private void read() throws IOException {
  final File ditalist=new File(tempDir,FILE_NAME_DITA_LIST);
  final File xmlDitalist=new File(tempDir,FILE_NAME_DITA_LIST_XML);
  InputStream in=null;
  try {
    if (xmlDitalist.exists()) {
      in=new FileInputStream(xmlDitalist);
      prop.loadFromXML(in);
    }
 else     if (ditalist.exists()) {
      in=new FileInputStream(ditalist);
      prop.load(in);
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
  }
 catch (  final IOException e) {
    throw new IOException("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    if (in != null) {
      try {
        in.close();
      }
 catch (      final IOException e) {
        throw new IOException("String_Node_Str" + e.getMessage(),e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Read temporary configuration files.
 * @throws IOException if reading configuration files failed
 * @throws IllegalStateException if configuration files are missing
 */
private void read() throws IOException {
  final File ditalist=new File(tempDir,FILE_NAME_DITA_LIST);
  final File xmlDitalist=new File(tempDir,FILE_NAME_DITA_LIST_XML);
  InputStream in=null;
  try {
    if (xmlDitalist.exists()) {
      in=new FileInputStream(xmlDitalist);
      prop.loadFromXML(in);
    }
 else     if (ditalist.exists()) {
      in=new FileInputStream(ditalist);
      prop.load(in);
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
  }
 catch (  final IOException e) {
    throw new IOException("String_Node_Str" + e.getMessage());
  }
 finally {
    if (in != null) {
      try {
        in.close();
      }
 catch (      final IOException e) {
        throw new IOException("String_Node_Str" + e.getMessage());
      }
    }
  }
}
Program: 100833
Project: 100833
Buggy source:
/** 
 * Store job into temporary configuration files.
 * @throws IOException if writing configuration files failed
 */
public void write() throws IOException {
  FileOutputStream propertiesOutputStream=null;
  try {
    propertiesOutputStream=new FileOutputStream(new File(tempDir,FILE_NAME_DITA_LIST));
    prop.store(propertiesOutputStream,null);
    propertiesOutputStream.flush();
  }
 catch (  final IOException e) {
    throw new IOException("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    if (propertiesOutputStream != null) {
      try {
        propertiesOutputStream.close();
      }
 catch (      final IOException e) {
        throw new IOException("String_Node_Str" + e.getMessage(),e);
      }
    }
  }
  FileOutputStream xmlOutputStream=null;
  try {
    xmlOutputStream=new FileOutputStream(new File(tempDir,FILE_NAME_DITA_LIST_XML));
    prop.storeToXML(xmlOutputStream,null);
    xmlOutputStream.flush();
  }
 catch (  final IOException e) {
    throw new IOException("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    if (xmlOutputStream != null) {
      try {
        xmlOutputStream.close();
      }
 catch (      final IOException e) {
        throw new IOException("String_Node_Str" + e.getMessage(),e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Store job into temporary configuration files.
 * @throws IOException if writing configuration files failed
 */
public void write() throws IOException {
  FileOutputStream propertiesOutputStream=null;
  try {
    propertiesOutputStream=new FileOutputStream(new File(tempDir,FILE_NAME_DITA_LIST));
    prop.store(propertiesOutputStream,null);
    propertiesOutputStream.flush();
  }
 catch (  final IOException e) {
    throw new IOException("String_Node_Str" + e.getMessage());
  }
 finally {
    if (propertiesOutputStream != null) {
      try {
        propertiesOutputStream.close();
      }
 catch (      final IOException e) {
        throw new IOException("String_Node_Str" + e.getMessage());
      }
    }
  }
  FileOutputStream xmlOutputStream=null;
  try {
    xmlOutputStream=new FileOutputStream(new File(tempDir,FILE_NAME_DITA_LIST_XML));
    prop.storeToXML(xmlOutputStream,null);
    xmlOutputStream.flush();
  }
 catch (  final IOException e) {
    throw new IOException("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    if (xmlOutputStream != null) {
      try {
        xmlOutputStream.close();
      }
 catch (      final IOException e) {
        throw new IOException("String_Node_Str" + e.getMessage(),e);
      }
    }
  }
}
Program: 100834
Project: 100834
Buggy source:
/** 
 * Store job into temporary configuration files.
 * @throws IOException if writing configuration files failed
 */
public void write() throws IOException {
  FileOutputStream propertiesOutputStream=null;
  try {
    propertiesOutputStream=new FileOutputStream(new File(tempDir,FILE_NAME_DITA_LIST));
    prop.store(propertiesOutputStream,null);
    propertiesOutputStream.flush();
  }
 catch (  final IOException e) {
    throw new IOException("String_Node_Str" + e.getMessage());
  }
 finally {
    if (propertiesOutputStream != null) {
      try {
        propertiesOutputStream.close();
      }
 catch (      final IOException e) {
        throw new IOException("String_Node_Str" + e.getMessage());
      }
    }
  }
  FileOutputStream xmlOutputStream=null;
  try {
    xmlOutputStream=new FileOutputStream(new File(tempDir,FILE_NAME_DITA_LIST_XML));
    prop.storeToXML(xmlOutputStream,null);
    xmlOutputStream.flush();
  }
 catch (  final IOException e) {
    throw new IOException("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    if (xmlOutputStream != null) {
      try {
        xmlOutputStream.close();
      }
 catch (      final IOException e) {
        throw new IOException("String_Node_Str" + e.getMessage(),e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Store job into temporary configuration files.
 * @throws IOException if writing configuration files failed
 */
public void write() throws IOException {
  FileOutputStream propertiesOutputStream=null;
  try {
    propertiesOutputStream=new FileOutputStream(new File(tempDir,FILE_NAME_DITA_LIST));
    prop.store(propertiesOutputStream,null);
    propertiesOutputStream.flush();
  }
 catch (  final IOException e) {
    throw new IOException("String_Node_Str" + e.getMessage());
  }
 finally {
    if (propertiesOutputStream != null) {
      try {
        propertiesOutputStream.close();
      }
 catch (      final IOException e) {
        throw new IOException("String_Node_Str" + e.getMessage());
      }
    }
  }
  FileOutputStream xmlOutputStream=null;
  try {
    xmlOutputStream=new FileOutputStream(new File(tempDir,FILE_NAME_DITA_LIST_XML));
    prop.storeToXML(xmlOutputStream,null);
    xmlOutputStream.flush();
  }
 catch (  final IOException e) {
    throw new IOException("String_Node_Str" + e.getMessage());
  }
 finally {
    if (xmlOutputStream != null) {
      try {
        xmlOutputStream.close();
      }
 catch (      final IOException e) {
        throw new IOException("String_Node_Str" + e.getMessage());
      }
    }
  }
}
Program: 100837
Project: 100837
Buggy source:
@AfterClass public static void tearDown() throws IOException {
}

Fixed version (ground truth):
@AfterClass public static void tearDown() throws IOException {
  TestUtils.forceDelete(tempDir);
}
Program: 100838
Project: 100838
Buggy source:
@BeforeClass public static void setUp() throws IOException, DITAOTException {
  tempDir=TestUtils.createTempDir(TestCHMIndexWriter.class);
  final DocumentBuilderFactory factory=new HTMLDocumentBuilderFactory();
  XMLUnit.setControlDocumentBuilderFactory(factory);
  XMLUnit.setTestDocumentBuilderFactory(factory);
  XMLUnit.setIgnoreWhitespace(true);
  XMLUnit.setIgnoreComments(true);
}

Fixed version (ground truth):
@BeforeClass public static void setUp() throws IOException, DITAOTException {
  tempDir=TestUtils.createTempDir(TestCHMIndexWriter.class);
  final DocumentBuilderFactory factory=new HTMLDocumentBuilderFactory();
  XMLUnit.setControlDocumentBuilderFactory(factory);
  XMLUnit.setTestDocumentBuilderFactory(factory);
  XMLUnit.setControlEntityResolver(null);
  XMLUnit.setTestEntityResolver(null);
  XMLUnit.setIgnoreWhitespace(true);
  XMLUnit.setIgnoreComments(true);
}
Program: 100839
Project: 100839
Buggy source:
@AfterClass public static void tearDown() throws IOException {
}

Fixed version (ground truth):
@AfterClass public static void tearDown() throws IOException {
  TestUtils.forceDelete(tempDir);
}
Program: 100840
Project: 100840
Buggy source:
public void write(final String filename) throws DITAOTException {
  final File inputFile=new File(filename);
  final File outputFile=new File(filename + FILE_EXTENSION_TEMP);
  try {
    final Transformer transformer=TransformerFactory.newInstance().newTransformer();
    final XMLReader reader=StringUtils.getXMLReader();
    setParent(reader);
    final Source source=new SAXSource(this,new InputSource(inputFile.toURI().toString()));
    final Result result=new StreamResult(outputFile.toURI().toString());
    transformer.transform(source,result);
    if (!inputFile.delete()) {
      final Properties prop=new Properties();
      prop.put("String_Node_Str",inputFile.getPath());
      prop.put("String_Node_Str",outputFile.getPath());
      logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    }
    if (!outputFile.renameTo(inputFile)) {
      final Properties prop=new Properties();
      prop.put("String_Node_Str",inputFile.getPath());
      prop.put("String_Node_Str",outputFile.getPath());
      logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    }
  }
 catch (  final Exception e) {
    logger.logException(e);
  }
}

Fixed version (ground truth):
public void write(final String filename) throws DITAOTException {
  final File inputFile=new File(filename);
  final File outputFile=new File(filename + FILE_EXTENSION_TEMP);
  InputStream in=null;
  OutputStream out=null;
  try {
    final Transformer transformer=TransformerFactory.newInstance().newTransformer();
    final XMLReader reader=StringUtils.getXMLReader();
    setParent(reader);
    setContentHandler(null);
    in=new BufferedInputStream(new FileInputStream(inputFile));
    out=new BufferedOutputStream(new FileOutputStream(outputFile));
    final Source source=new SAXSource(this,new InputSource(in));
    final Result result=new StreamResult(out);
    transformer.transform(source,result);
  }
 catch (  final Exception e) {
    logger.logException(e);
  }
 finally {
    if (in != null) {
      try {
        in.close();
      }
 catch (      IOException e) {
        logger.logException(e);
      }
    }
    if (out != null) {
      try {
        out.close();
      }
 catch (      IOException e) {
        logger.logException(e);
      }
    }
  }
  try {
    if (!inputFile.delete()) {
      final Properties prop=new Properties();
      prop.put("String_Node_Str",inputFile.getPath());
      prop.put("String_Node_Str",outputFile.getPath());
      logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    }
    if (!outputFile.renameTo(inputFile)) {
      final Properties prop=new Properties();
      prop.put("String_Node_Str",inputFile.getPath());
      prop.put("String_Node_Str",outputFile.getPath());
      logger.logError(MessageUtils.getMessage("String_Node_Str",prop).toString());
    }
  }
 catch (  final Exception e) {
    logger.logException(e);
  }
}
Program: 100841
Project: 100841
Buggy source:
/** 
 * Write end element.
 * @throws SAXException if processing the event failed
 */
public void writeEndElement() throws SAXException {
  processStartElement();
  final QName qName=elementStack.remove();
  transformer.endElement(qName.uri,qName.localName,qName.prefix);
  for (  NamespaceMapping p : qName.mappings) {
    if (p.newMapping) {
      transformer.endPrefixMapping(p.prefix);
    }
  }
}

Fixed version (ground truth):
/** 
 * Write end element.
 * @throws SAXException if processing the event failed
 */
public void writeEndElement() throws SAXException {
  processStartElement();
  final QName qName=elementStack.remove();
  transformer.endElement(qName.uri,qName.localName,qName.qName);
  for (  NamespaceMapping p : qName.mappings) {
    if (p.newMapping) {
      transformer.endPrefixMapping(p.prefix);
    }
  }
}
Program: 100842
Project: 100842
Buggy source:
/** 
 * End document.
 * @throws SAXException if processing the event failed
 */
public void writeEndDocument() throws SAXException {
  transformer.endDocument();
}

Fixed version (ground truth):
/** 
 * End document.
 * @throws SAXException if processing the event failed
 */
public void writeEndDocument() throws SAXException {
  while (!elementStack.isEmpty()) {
    writeEndElement();
  }
  transformer.endDocument();
}
Program: 100843
Project: 100843
Buggy source:
private void processStartElement() throws SAXException {
  if (openStartElement) {
    final QName qName=elementStack.peek();
    if (qName.newMapping) {
      transformer.startPrefixMapping(qName.prefix,qName.uri);
    }
    final Attributes atts=openAttributes != null ? openAttributes : EMPTY_ATTS;
    transformer.startElement(qName.uri,qName.localName,qName.qName,atts);
    openStartElement=false;
    openAttributes=null;
  }
}

Fixed version (ground truth):
private void processStartElement() throws SAXException {
  if (openStartElement) {
    final QName qName=elementStack.getFirst();
    for (    NamespaceMapping p : qName.mappings) {
      if (p.newMapping) {
        transformer.startPrefixMapping(p.prefix,p.uri);
      }
    }
    final Attributes atts=openAttributes != null ? openAttributes : EMPTY_ATTS;
    transformer.startElement(qName.uri,qName.localName,qName.qName,atts);
    openStartElement=false;
    openAttributes=null;
  }
}
Program: 100844
Project: 100844
Buggy source:
QName(final String uri,final String qName){
  final int i=qName.indexOf(':');
  this.uri=uri != null ? uri : DEFAULT_NS_PREFIX;
  this.localName=i != -1 ? qName.substring(i + 1) : qName;
  this.prefix=i != -1 ? qName.substring(0,i) : DEFAULT_NS_PREFIX;
  this.qName=qName;
}

Fixed version (ground truth):
QName(final String uri,final String qName){
  final int i=qName.indexOf(':');
  this.uri=uri != null ? uri : DEFAULT_NS_PREFIX;
  this.localName=i != -1 ? qName.substring(i + 1) : qName;
  this.prefix=i != -1 ? qName.substring(0,i) : DEFAULT_NS_PREFIX;
  this.qName=qName;
  this.mappings=new ArrayList<NamespaceMapping>(5);
}
Program: 100845
Project: 100845
Buggy source:
/** 
 * Write characters.
 * @param text character data
 * @throws SAXException if processing the event failed
 */
public void writeCharacters(final String text) throws SAXException {
  processStartElement();
  final char[] ch=text.toCharArray();
  transformer.characters(ch,0,ch.length);
}

Fixed version (ground truth):
/** 
 * Write characters.
 * @param text character data
 * @throws SAXException if processing the event failed
 * @throws IllegalStateException if start element is not open
 */
public void writeCharacters(final char[] ch,final int start,final int length) throws SAXException {
  if (elementStack.isEmpty())   throw new IllegalStateException("String_Node_Str");
  processStartElement();
  transformer.characters(ch,0,ch.length);
}
Program: 100846
Project: 100846
Buggy source:
/** 
 * Writer start element without attributes.
 * @param qName element QName
 * @throws SAXException if processing the event failed
 */
public void writeStartElement(final String uri,final String qName) throws SAXException {
  processStartElement();
  final QName res=new QName(uri,qName);
  if (uri != null) {
    boolean found=false;
    for (    final QName e : elementStack) {
      if (e.uri.equals(res.uri) && e.prefix.equals(res.prefix)) {
        found=true;
        break;
      }
    }
    res.newMapping=!found;
  }
  elementStack.push(res);
  openStartElement=true;
}

Fixed version (ground truth):
/** 
 * Write start element without attributes.
 * @param qName element QName
 * @throws SAXException if processing the event failed
 */
public void writeStartElement(final String uri,final String qName) throws SAXException {
  processStartElement();
  final QName res=new QName(uri,qName);
  addNamespace(res.uri,res.prefix,res);
  elementStack.addFirst(res);
  openStartElement=true;
}
Program: 100847
Project: 100847
Buggy source:
/** 
 * Write end element.
 * @throws SAXException if processing the event failed
 */
public void writeEndElement() throws SAXException {
  processStartElement();
  final QName qName=elementStack.pop();
  transformer.endElement(qName.uri,qName.localName,qName.prefix);
  if (qName.newMapping) {
    transformer.endPrefixMapping(qName.prefix);
  }
}

Fixed version (ground truth):
/** 
 * Write end element.
 * @throws SAXException if processing the event failed
 */
public void writeEndElement() throws SAXException {
  processStartElement();
  final QName qName=elementStack.remove();
  transformer.endElement(qName.uri,qName.localName,qName.prefix);
  for (  NamespaceMapping p : qName.mappings) {
    if (p.newMapping) {
      transformer.endPrefixMapping(p.prefix);
    }
  }
}
Program: 100848
Project: 100848
Buggy source:
/** 
 * Write attribute
 * @param qName attribute name
 * @param atts attribute value
 * @throws SAXException if processing the event failed
 */
public void writeAttribute(final String qName,final String value) throws SAXException {
  if (openAttributes == null) {
    openAttributes=new AttributesImpl();
  }
  openAttributes.addAttribute("String_Node_Str",qName,qName,"String_Node_Str",value);
}

Fixed version (ground truth):
/** 
 * Write attribute
 * @param uri namespace URI
 * @param qName attribute name
 * @param atts attribute value
 * @throws SAXException if processing the event failed
 * @throws IllegalStateException if start element is not open
 */
public void writeAttribute(final String uri,final String qName,final String value) throws SAXException {
  if (!openStartElement)   throw new IllegalStateException("String_Node_Str");
  if (openAttributes == null) {
    openAttributes=new AttributesImpl();
  }
  final QName att=new QName(uri,qName);
  addNamespace(uri,att.prefix,elementStack.getFirst());
  openAttributes.addAttribute(uri,att.localName,qName,"String_Node_Str",value);
}
Program: 100849
Project: 100849
Buggy source:
/** 
 * Init xml reader used for pipeline parsing.
 * @param ditaDir ditaDir
 * @param validate whether validate input file
 * @param rootFile input file
 * @throws SAXException parsing exception
 */
public void initXMLReader(String ditaDir,boolean validate,String rootFile,boolean arg_setSystemid) throws SAXException {
  rootDir=new File(rootFile).getAbsoluteFile().getParent();
  rootDir=FileUtils.removeRedundantNames(rootDir);
  rootFilePath=new File(rootFile).getAbsolutePath();
  rootFilePath=FileUtils.removeRedundantNames(rootFilePath);
  reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
  if (validate == true) {
    reader.setFeature(FEATURE_VALIDATION,true);
    reader.setFeature(FEATURE_VALIDATION_SCHEMA,true);
  }
 else {
    final String msg=MessageUtils.getMessage("String_Node_Str").toString();
    logger.logWarn(msg);
  }
  final XMLGrammarPool grammarPool=GrammarPoolManager.getGrammarPool();
  setGrammarPool(reader,grammarPool);
  CatalogUtils.setDitaDir(ditaDir);
  catalogMap=CatalogUtils.getCatalog(ditaDir);
  setSystemid=arg_setSystemid;
}

Fixed version (ground truth):
/** 
 * Init xml reader used for pipeline parsing.
 * @param ditaDir ditaDir
 * @param validate whether validate input file
 * @param rootFile input file
 * @throws SAXException parsing exception
 */
public void initXMLReader(String ditaDir,boolean validate,String rootFile,boolean arg_setSystemid) throws SAXException {
  rootDir=new File(rootFile).getAbsoluteFile().getParent();
  rootDir=FileUtils.removeRedundantNames(rootDir);
  rootFilePath=new File(rootFile).getAbsolutePath();
  rootFilePath=FileUtils.removeRedundantNames(rootFilePath);
  reader.setFeature(FEATURE_NAMESPACE_PREFIX,true);
  if (validate == true) {
    reader.setFeature(FEATURE_VALIDATION,true);
    reader.setFeature(FEATURE_VALIDATION_SCHEMA,true);
  }
 else {
    final String msg=MessageUtils.getMessage("String_Node_Str").toString();
    logger.logWarn(msg);
  }
  final XMLGrammarPool grammarPool=GrammarPoolManager.getGrammarPool();
  setGrammarPool(reader,grammarPool);
  CatalogUtils.setDitaDir(ditaDir);
  catalogMap=CatalogUtils.getCatalog(ditaDir);
  setSystemid=arg_setSystemid;
  try {
    Class.forName(RESOLVER_CLASS);
    reader.setEntityResolver(CatalogUtils.getCatalogResolver());
  }
 catch (  final ClassNotFoundException e) {
    reader.setEntityResolver(this);
  }
}