nus-yam/ex-repair huggingface dataset:
Program: 53383
Project: 53383
Buggy source:
/** 
 * This method receives as input an array of tokenized text and calls the NameFinderME.find(tokens) to recognize and classify Named Entities. It outputs the spans of the detected and classified Named Entities. From Apache OpenNLP documentation: "After every document clearAdaptiveData must be called to clear the adaptive data in the feature generators. Not calling clearAdaptiveData can lead to a sharp drop in the detection rate after a few documents."
 * @param tokens an array of tokenized text
 * @return an list of {@link Span}s of Named Entities
 */
public final Span[] nercToSpans(final String[] tokens){
  Span[] annotatedText=nameFinder.find(tokens);
  clearAdaptiveData();
  List<Span> probSpans=new ArrayList<Span>(Arrays.asList(annotatedText));
  return probSpans.toArray(new Span[probSpans.size()]);
}

Fixed version (ground truth):
/** 
 * This method receives as input an array of tokenized text and calls the NameFinderME.find(tokens) to recognize and classify Named Entities. It outputs the spans of the detected and classified Named Entities. From Apache OpenNLP documentation: "After every document clearAdaptiveData must be called to clear the adaptive data in the feature generators. Not calling clearAdaptiveData can lead to a sharp drop in the detection rate after a few documents."
 * @param tokens an array of tokenized text
 * @return an list of {@link Span}s of Named Entities
 */
public final Span[] nercToSpans(final String[] tokens){
  Span[] annotatedText=nameFinder.find(tokens);
  List<Span> probSpans=new ArrayList<Span>(Arrays.asList(annotatedText));
  return probSpans.toArray(new Span[probSpans.size()]);
}
Program: 53386
Project: 53386
Buggy source:
/** 
 * Adds the dictionary features of the curren token in a given window.
 * @param leftWindow the left window
 * @param rightWindow the right window
 * @param featureList the feature list
 */
private static void addDictionaryFeatures(int leftWindow,int rightWindow,final List<AdaptiveFeatureGenerator> featureList){
  for (int i=0; i < dictionaries.getIgnoreCaseDictionaries().size(); i++) {
    prefix=dictionaries.getDictNames().get(i);
    dictionary=dictionaries.getIgnoreCaseDictionaries().get(i);
    featureList.add(new WindowFeatureGenerator(leftWindow,rightWindow,new DictionaryFeatureGenerator(prefix,dictionary)));
  }
}

Fixed version (ground truth):
/** 
 * Adds the dictionary features of the curren token in a given window.
 * @param leftWindow the left window
 * @param rightWindow the right window
 * @param featureList the feature list
 */
private static void addDictionaryFeatures(final List<AdaptiveFeatureGenerator> featureList){
  for (int i=0; i < dictionaries.getIgnoreCaseDictionaries().size(); i++) {
    prefix=dictionaries.getDictNames().get(i);
    dictionary=dictionaries.getIgnoreCaseDictionaries().get(i);
    featureList.add(new DictionaryFeatureGenerator(prefix,dictionary));
  }
}
Program: 53387
Project: 53387
Buggy source:
/** 
 * Adds the previous outcome for each token as a feature.
 * @param featureList the feature list to which the feature generator is added
 */
public static void addPreviousMapFeatures(int leftWindow,int rightWindow,List<AdaptiveFeatureGenerator> featureList){
  featureList.add(new Prev2MapFeatureGenerator());
  featureList.add(new WindowFeatureGenerator(leftWindow,rightWindow,new PreviousMapTokenFeatureGenerator()));
}

Fixed version (ground truth):
/** 
 * Adds the previous outcome for each token as a feature.
 * @param featureList the feature list to which the feature generator is added
 */
public static void addPreviousMapFeatures(int leftWindow,int rightWindow,List<AdaptiveFeatureGenerator> featureList){
  featureList.add(new PreviousMapFeatureGenerator());
}
Program: 53388
Project: 53388
Buggy source:
/** 
 * Adds Brown classes features for each token feature in a given window.
 * @param leftWindow the leftwindow value
 * @param rightWindow the rightwindow value
 * @param featureList the feature list to which the feature generator is added
 */
private static void addBrownFeatures(int leftWindow,int rightWindow,final List<AdaptiveFeatureGenerator> featureList){
  featureList.add(new WindowFeatureGenerator(new BrownTokenFeatureGenerator(brownLexicon),leftWindow,rightWindow));
  featureList.add(new WindowFeatureGenerator(new BrownTokenClassFeatureGenerator(brownLexicon),leftWindow,rightWindow));
  featureList.add(new BrownBigramFeatureGenerator(brownLexicon));
}

Fixed version (ground truth):
/** 
 * Adds Brown classes features for each token feature in a given window.
 * @param leftWindow the leftwindow value
 * @param rightWindow the rightwindow value
 * @param featureList the feature list to which the feature generator is added
 */
private static void addBrownFeatures(final List<AdaptiveFeatureGenerator> featureList){
  featureList.add(new BrownTokenFeatureGenerator(brownLexicon));
  featureList.add(new BrownTokenClassFeatureGenerator(brownLexicon));
  featureList.add(new BrownBigramFeatureGenerator(brownLexicon));
}
Program: 53389
Project: 53389
Buggy source:
/** 
 * Add the word2vec cluster class feature of the curren token in a given window.
 * @param leftWindow the left window
 * @param rightWindow the right window
 * @param featureList the feature list
 */
private static void addWord2VecClusterFeatures(int leftWindow,int rightWindow,final List<AdaptiveFeatureGenerator> featureList){
  word2vecClusterLexicon=word2vecCluster.getIgnoreCaseDictionary();
  featureList.add(new WindowFeatureGenerator(leftWindow,rightWindow,new Word2VecClusterFeatureGenerator(word2vecClusterLexicon)));
}

Fixed version (ground truth):
/** 
 * Add the word2vec cluster class feature of the curren token in a given window.
 * @param leftWindow the left window
 * @param rightWindow the right window
 * @param featureList the feature list
 */
private static void addWord2VecClusterFeatures(final List<AdaptiveFeatureGenerator> featureList){
  word2vecClusterLexicon=word2vecCluster.getIgnoreCaseDictionary();
  featureList.add(Word2VecClusterFeatureGenerator(word2vecClusterLexicon));
}
Program: 53390
Project: 53390
Buggy source:
/** 
 * Add the Clark cluster class of the current token as a feature in a given window.
 * @param leftWindow the left window
 * @param rightWindow the right window
 * @param featureList the feature list
 */
private static void addClarkFeatures(int leftWindow,int rightWindow,final List<AdaptiveFeatureGenerator> featureList){
  clarkLexicon=clarkCluster.getIgnoreCaseDictionary();
  featureList.add(new WindowFeatureGenerator(leftWindow,rightWindow,new ClarkFeatureGenerator(clarkLexicon)));
}

Fixed version (ground truth):
/** 
 * Add the Clark cluster class of the current token as a feature in a given window.
 * @param leftWindow the left window
 * @param rightWindow the right window
 * @param featureList the feature list
 */
private static void addClarkFeatures(final List<AdaptiveFeatureGenerator> featureList){
  clarkLexicon=clarkCluster.getIgnoreCaseDictionary();
  featureList.add(new ClarkFeatureGenerator(clarkLexicon));
}
Program: 53394
Project: 53394
Buggy source:
public String getTermSpanCommentValue(Comment spanComment){
  String spanCommentValue=null;
  if (spanComment.getValue() == null) {
    spanCommentValue="String_Node_Str";
  }
 else {
    spanCommentValue=spanComment.getValue();
  }
  return spanCommentValue;
}

Fixed version (ground truth):
public String getTermSpanCommentValue(Comment spanComment){
  String spanCommentValue=null;
  if (spanComment.getValue() == null) {
    spanCommentValue="String_Node_Str";
  }
  if (spanComment.getValue().startsWith("String_Node_Str") || spanComment.getValue().endsWith("String_Node_Str")) {
    spanCommentValue=spanComment.getValue().replace("String_Node_Str","String_Node_Str");
  }
 else {
    spanCommentValue=spanComment.getValue();
  }
  return spanCommentValue;
}
Program: 53395
Project: 53395
Buggy source:
/** 
 * It takes a NE span indexes and the tokens in a sentence and produces the string to which the NE span corresponds to. This function is used to get the NE textual representation from a Span. The NE string will then be added to the span element in the <entities> layer of the KAF document.
 * @param Span reducedSpan
 * @param String [] tokens
 * @return named entity string
 */
private String getStringFromSpan(Span reducedSpan,String[] tokens){
  StringBuilder sb=new StringBuilder();
  for (int si=reducedSpan.getStart(); si < reducedSpan.getEnd(); si++) {
    sb.append(tokens[si]).append("String_Node_Str");
  }
  String neString=sb.toString();
  return neString;
}

Fixed version (ground truth):
/** 
 * It takes a NE span indexes and the tokens in a sentence and produces the string to which the NE span corresponds to. This function is used to get the NE textual representation from a Span. The NE string will then be added to the span element in the <entities> layer of the KAF document.
 * @param Span reducedSpan
 * @param String [] tokens
 * @return named entity string
 */
private String getStringFromSpan(Span reducedSpan,String[] tokens){
  StringBuilder sb=new StringBuilder();
  for (int si=reducedSpan.getStart(); si < reducedSpan.getEnd(); si++) {
    sb.append(tokens[si]).append("String_Node_Str");
  }
  String neString=null;
  if (sb.toString().startsWith("String_Node_Str") || sb.toString().endsWith("String_Node_Str")) {
    neString=sb.toString().replace("String_Node_Str","String_Node_Str");
  }
 else {
    neString=sb.toString();
  }
  return neString;
}
Program: 53396
Project: 53396
Buggy source:
@Override public void serializeToResValuesXml(XmlSerializer serializer,ResResource res) throws IOException, AndrolibException {
  String type=res.getResSpec().getType().getName();
  boolean item=!"String_Node_Str".equals(mType) && !type.equals(mType);
  String body=encodeAsResXmlValue();
  if (body.contains("String_Node_Str")) {
    if (!res.getFilePath().contains("String_Node_Str")) {
      item=true;
    }
  }
  String tagName=item ? "String_Node_Str" : type;
  serializer.startTag(null,tagName);
  if (item) {
    serializer.attribute(null,"String_Node_Str",type);
  }
  serializer.attribute(null,"String_Node_Str",res.getResSpec().getName());
  serializeExtraXmlAttrs(serializer,res);
  if (!body.isEmpty()) {
    serializer.ignorableWhitespace(body);
  }
  serializer.endTag(null,tagName);
}

Fixed version (ground truth):
@Override public void serializeToResValuesXml(XmlSerializer serializer,ResResource res) throws IOException, AndrolibException {
  String type=res.getResSpec().getType().getName();
  boolean item=!"String_Node_Str".equals(mType) && !type.equals(mType);
  String body=encodeAsResXmlValue();
  if (!type.equalsIgnoreCase("String_Node_Str")) {
    if (body.contains("String_Node_Str")) {
      if (!res.getFilePath().contains("String_Node_Str")) {
        item=true;
      }
    }
  }
  String tagName=item ? "String_Node_Str" : type;
  serializer.startTag(null,tagName);
  if (item) {
    serializer.attribute(null,"String_Node_Str",type);
  }
  serializer.attribute(null,"String_Node_Str",res.getResSpec().getName());
  serializeExtraXmlAttrs(serializer,res);
  if (!body.isEmpty()) {
    serializer.ignorableWhitespace(body);
  }
  serializer.endTag(null,tagName);
}
Program: 53399
Project: 53399
Buggy source:
public void decodeSourcesSmali(File apkFile,File outDir,boolean debug,boolean bakdeb) throws AndrolibException {
  try {
    File smaliDir=new File(outDir,SMALI_DIRNAME);
    OS.rmdir(smaliDir);
    smaliDir.mkdirs();
    LOGGER.info("String_Node_Str");
    SmaliDecoder.decode(apkFile,smaliDir,debug,bakdeb);
  }
 catch (  BrutException ex) {
    throw new AndrolibException(ex);
  }
}

Fixed version (ground truth):
public void decodeSourcesSmali(File apkFile,File outDir,boolean debug,String debugLinePrefix,boolean bakdeb) throws AndrolibException {
  try {
    File smaliDir=new File(outDir,SMALI_DIRNAME);
    OS.rmdir(smaliDir);
    smaliDir.mkdirs();
    LOGGER.info("String_Node_Str");
    SmaliDecoder.decode(apkFile,smaliDir,debug,debugLinePrefix,bakdeb);
  }
 catch (  BrutException ex) {
    throw new AndrolibException(ex);
  }
}
Program: 53401
Project: 53401
Buggy source:
@Override public FileVisitResult visitFile(Path file,BasicFileAttributes attrs) throws IOException {
  String fileName=file.getFileName().toString();
  if (!fileName.endsWith("String_Node_Str")) {
    return FileVisitResult.CONTINUE;
  }
  fileName=fileName.substring(0,fileName.length() - 6);
  try (BufferedReader in=Files.newBufferedReader(file,Charset.defaultCharset());BufferedWriter out=Files.newBufferedWriter(file.resolveSibling(fileName + "String_Node_Str"),Charset.defaultCharset())){
    TypeName type=TypeName.fromPath(mOutDir.relativize(file.resolveSibling(fileName)));
    out.write("String_Node_Str" + type.package_ + "String_Node_Str"+ type.getName(true,true)+ "String_Node_Str");
    out.newLine();
    String line;
    while ((line=in.readLine()) != null) {
      out.write("String_Node_Str");
      out.write(line);
      out.newLine();
    }
    out.write("String_Node_Str");
    out.newLine();
  }
   Files.delete(file);
  return FileVisitResult.CONTINUE;
}

Fixed version (ground truth):
@Override public FileVisitResult visitFile(Path file,BasicFileAttributes attrs) throws IOException {
  String fileName=file.getFileName().toString();
  if (!fileName.endsWith("String_Node_Str")) {
    return FileVisitResult.CONTINUE;
  }
  fileName=fileName.substring(0,fileName.length() - 6);
  try (BufferedReader in=Files.newBufferedReader(file,Charset.defaultCharset());BufferedWriter out=Files.newBufferedWriter(file.resolveSibling(fileName + "String_Node_Str"),Charset.defaultCharset())){
    TypeName type=TypeName.fromPath(mOutDir.relativize(file.resolveSibling(fileName)));
    out.write("String_Node_Str" + type.package_ + "String_Node_Str"+ type.getName(true,true)+ "String_Node_Str");
    out.newLine();
    String line;
    final String debugLinePrefix=mDebugLinePrefix;
    while ((line=in.readLine()) != null) {
      out.write(debugLinePrefix);
      out.write(line);
      out.newLine();
    }
    out.write("String_Node_Str");
    out.newLine();
  }
   Files.delete(file);
  return FileVisitResult.CONTINUE;
}
Program: 53402
Project: 53402
Buggy source:
private SmaliDecoder(File apkFile,File outDir,boolean debug,boolean bakdeb){
  mApkFile=apkFile;
  mOutDir=outDir.toPath();
  mDebug=debug;
  mBakDeb=bakdeb;
}

Fixed version (ground truth):
private SmaliDecoder(File apkFile,File outDir,boolean debug,String debugLinePrefix,boolean bakdeb){
  mApkFile=apkFile;
  mOutDir=outDir.toPath();
  mDebug=debug;
  mDebugLinePrefix=debugLinePrefix;
  mBakDeb=bakdeb;
}
Program: 53405
Project: 53405
Buggy source:
public void decodeSourcesSmali(File apkFile,File outDir,boolean debug,boolean bakdeb) throws AndrolibException {
  try {
    File smaliDir=new File(outDir,SMALI_DIRNAME);
    OS.rmdir(smaliDir);
    smaliDir.mkdirs();
    LOGGER.info("String_Node_Str");
    SmaliDecoder.decode(apkFile,smaliDir,debug,bakdeb);
  }
 catch (  BrutException ex) {
    throw new AndrolibException(ex);
  }
}

Fixed version (ground truth):
public void decodeSourcesSmali(File apkFile,File outDir,boolean debug,String debugLinePrefix,boolean bakdeb) throws AndrolibException {
  try {
    File smaliDir=new File(outDir,SMALI_DIRNAME);
    OS.rmdir(smaliDir);
    smaliDir.mkdirs();
    LOGGER.info("String_Node_Str");
    SmaliDecoder.decode(apkFile,smaliDir,debug,debugLinePrefix,bakdeb);
  }
 catch (  BrutException ex) {
    throw new AndrolibException(ex);
  }
}
Program: 53407
Project: 53407
Buggy source:
@Override public FileVisitResult visitFile(Path file,BasicFileAttributes attrs) throws IOException {
  String fileName=file.getFileName().toString();
  if (!fileName.endsWith("String_Node_Str")) {
    return FileVisitResult.CONTINUE;
  }
  fileName=fileName.substring(0,fileName.length() - 6);
  try (BufferedReader in=Files.newBufferedReader(file,Charset.defaultCharset());BufferedWriter out=Files.newBufferedWriter(file.resolveSibling(fileName + "String_Node_Str"),Charset.defaultCharset())){
    TypeName type=TypeName.fromPath(mOutDir.relativize(file.resolveSibling(fileName)));
    out.write("String_Node_Str" + type.package_ + "String_Node_Str"+ type.getName(true,true)+ "String_Node_Str");
    out.newLine();
    String line;
    while ((line=in.readLine()) != null) {
      out.write("String_Node_Str");
      out.write(line);
      out.newLine();
    }
    out.write("String_Node_Str");
    out.newLine();
  }
   Files.delete(file);
  return FileVisitResult.CONTINUE;
}

Fixed version (ground truth):
@Override public FileVisitResult visitFile(Path file,BasicFileAttributes attrs) throws IOException {
  String fileName=file.getFileName().toString();
  if (!fileName.endsWith("String_Node_Str")) {
    return FileVisitResult.CONTINUE;
  }
  fileName=fileName.substring(0,fileName.length() - 6);
  try (BufferedReader in=Files.newBufferedReader(file,Charset.defaultCharset());BufferedWriter out=Files.newBufferedWriter(file.resolveSibling(fileName + "String_Node_Str"),Charset.defaultCharset())){
    TypeName type=TypeName.fromPath(mOutDir.relativize(file.resolveSibling(fileName)));
    out.write("String_Node_Str" + type.package_ + "String_Node_Str"+ type.getName(true,true)+ "String_Node_Str");
    out.newLine();
    String line;
    final String debugLinePrefix=mDebugLinePrefix;
    while ((line=in.readLine()) != null) {
      out.write(debugLinePrefix);
      out.write(line);
      out.newLine();
    }
    out.write("String_Node_Str");
    out.newLine();
  }
   Files.delete(file);
  return FileVisitResult.CONTINUE;
}
Program: 53408
Project: 53408
Buggy source:
private SmaliDecoder(File apkFile,File outDir,boolean debug,boolean bakdeb){
  mApkFile=apkFile;
  mOutDir=outDir.toPath();
  mDebug=debug;
  mBakDeb=bakdeb;
}

Fixed version (ground truth):
private SmaliDecoder(File apkFile,File outDir,boolean debug,String debugLinePrefix,boolean bakdeb){
  mApkFile=apkFile;
  mOutDir=outDir.toPath();
  mDebug=debug;
  mDebugLinePrefix=debugLinePrefix;
  mBakDeb=bakdeb;
}
Program: 53409
Project: 53409
Buggy source:
private boolean step(){
  String line=next();
  if (line.isEmpty()) {
    return false;
  }
switch (line.charAt(0)) {
case '#':
    return processComment(line);
case ':':
  append(line);
return false;
case '.':
return processDirective(line);
default :
return processInstruction(line);
}
}

Fixed version (ground truth):
private boolean step(){
  String line=next();
  if (line.isEmpty()) {
    return false;
  }
switch (line.charAt(0)) {
case '#':
    return processComment(line);
case ':':
  append(line);
return false;
case '.':
return processDirective(line);
default :
if (!areParamsInjected) {
injectRemainingParams();
}
return processInstruction(line);
}
}
Program: 53410
Project: 53410
Buggy source:
private void inject() throws AndrolibException {
  String definition=nextAndAppend();
  if (definition.contains("String_Node_Str") || definition.contains("String_Node_Str")) {
    nextAndAppend();
    return;
  }
  injectParameters(definition);
  boolean end=false;
  while (!end) {
    end=step();
  }
}

Fixed version (ground truth):
private void inject() throws AndrolibException {
  String definition=nextAndAppend();
  if (definition.contains("String_Node_Str") || definition.contains("String_Node_Str")) {
    nextAndAppend();
    return;
  }
  parseParamsNumber(definition);
  boolean end=false;
  while (!end) {
    end=step();
  }
}
Program: 53411
Project: 53411
Buggy source:
private boolean processDirective(String line){
  String line2=line.substring(1);
  if (line2.startsWith("String_Node_Str") || line2.equals("String_Node_Str") || line2.startsWith("String_Node_Str")|| line2.startsWith("String_Node_Str")|| line2.startsWith("String_Node_Str")) {
    return false;
  }
  append(line);
  if (line2.equals("String_Node_Str")) {
    return true;
  }
  if (line2.startsWith("String_Node_Str") || line2.equals("String_Node_Str") || line2.startsWith("String_Node_Str")|| line2.startsWith("String_Node_Str")) {
    while (true) {
      line2=nextAndAppend();
      if (line2.startsWith("String_Node_Str")) {
        break;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean processDirective(String line){
  String line2=line.substring(1);
  if (line2.startsWith("String_Node_Str") || line2.startsWith("String_Node_Str") || line2.startsWith("String_Node_Str")) {
    return false;
  }
  if (line2.equals("String_Node_Str")) {
    if (!areParamsInjected) {
      injectRemainingParams();
    }
    return false;
  }
  if (line2.equals("String_Node_Str")) {
    mOut.append("String_Node_Str").append(currParam++).append("String_Node_Str");
    return false;
  }
  append(line);
  if (line2.equals("String_Node_Str")) {
    return true;
  }
  if (line2.startsWith("String_Node_Str") || line2.equals("String_Node_Str") || line2.startsWith("String_Node_Str")|| line2.startsWith("String_Node_Str")) {
    while (true) {
      line2=nextAndAppend();
      if (line2.startsWith("String_Node_Str")) {
        break;
      }
    }
  }
  return false;
}
Program: 53413
Project: 53413
Buggy source:
public void build(ExtFile appDir,File outFile,HashMap<String,Boolean> flags,ExtFile origApk,String aaptPath) throws BrutException {
  mAaptPath=aaptPath;
  Map<String,Object> meta=readMetaFile(appDir);
  Object t1=meta.get("String_Node_Str");
  flags.put("String_Node_Str",t1 == null ? false : (Boolean)t1);
  mAndRes.setSdkInfo((Map<String,String>)meta.get("String_Node_Str"));
  if (flags.get("String_Node_Str")) {
    if (!origApk.isFile() || !origApk.canRead()) {
      throw new InFileNotFoundException();
    }
 else {
      mOrigApkFile=origApk;
    }
  }
  if (outFile == null) {
    String outFileName=(String)meta.get("String_Node_Str");
    outFile=new File(appDir,"String_Node_Str" + File.separator + (outFileName == null ? "String_Node_Str" : outFileName));
  }
  new File(appDir,APK_DIRNAME).mkdirs();
  buildSources(appDir,flags);
  buildResources(appDir,flags,(Map<String,Object>)meta.get("String_Node_Str"));
  buildLib(appDir,flags);
  buildApk(appDir,outFile,flags);
}

Fixed version (ground truth):
public void build(ExtFile appDir,File outFile,HashMap<String,Boolean> flags,ExtFile origApk,String aaptPath) throws BrutException {
  mAaptPath=aaptPath;
  Map<String,Object> meta=readMetaFile(appDir);
  Object t1=meta.get("String_Node_Str");
  flags.put("String_Node_Str",t1 == null ? false : (Boolean)t1);
  flags.put("String_Node_Str",meta.get("String_Node_Str") == null ? false : (Boolean)meta.get("String_Node_Str"));
  mAndRes.setSdkInfo((Map<String,String>)meta.get("String_Node_Str"));
  if (flags.get("String_Node_Str")) {
    if (!origApk.isFile() || !origApk.canRead()) {
      throw new InFileNotFoundException();
    }
 else {
      mOrigApkFile=origApk;
    }
  }
  if (outFile == null) {
    String outFileName=(String)meta.get("String_Node_Str");
    outFile=new File(appDir,"String_Node_Str" + File.separator + (outFileName == null ? "String_Node_Str" : outFileName));
  }
  new File(appDir,APK_DIRNAME).mkdirs();
  buildSources(appDir,flags);
  buildResources(appDir,flags,(Map<String,Object>)meta.get("String_Node_Str"));
  buildLib(appDir,flags);
  buildApk(appDir,outFile,flags);
}
Program: 53414
Project: 53414
Buggy source:
public void decode() throws AndrolibException {
  File outDir=getOutDir();
  if (!mForceDelete && outDir.exists()) {
    throw new OutDirExistsException();
  }
  if (!mApkFile.isFile() || !mApkFile.canRead()) {
    throw new InFileNotFoundException();
  }
  try {
    OS.rmdir(outDir);
  }
 catch (  BrutException ex) {
    throw new AndrolibException(ex);
  }
  outDir.mkdirs();
  if (hasSources()) {
switch (mDecodeSources) {
case DECODE_SOURCES_NONE:
      mAndrolib.decodeSourcesRaw(mApkFile,outDir,mDebug);
    break;
case DECODE_SOURCES_SMALI:
  mAndrolib.decodeSourcesSmali(mApkFile,outDir,mDebug,mBakDeb);
break;
case DECODE_SOURCES_JAVA:
mAndrolib.decodeSourcesJava(mApkFile,outDir,mDebug);
break;
}
}
if (hasResources()) {
switch (mDecodeResources) {
case DECODE_RESOURCES_NONE:
mAndrolib.decodeResourcesRaw(mApkFile,outDir);
break;
case DECODE_RESOURCES_FULL:
mAndrolib.decodeResourcesFull(mApkFile,outDir,getResTable());
break;
}
}
 else {
if (hasManifest()) {
switch (mDecodeResources) {
case DECODE_RESOURCES_NONE:
mAndrolib.decodeManifestRaw(mApkFile,outDir);
break;
case DECODE_RESOURCES_FULL:
mAndrolib.decodeManifestFull(mApkFile,outDir,getResTable());
break;
}
}
}
mAndrolib.decodeRawFiles(mApkFile,outDir);
writeMetaFile();
}

Fixed version (ground truth):
public void decode() throws AndrolibException, IOException {
  File outDir=getOutDir();
  if (!mForceDelete && outDir.exists()) {
    throw new OutDirExistsException();
  }
  if (!mApkFile.isFile() || !mApkFile.canRead()) {
    throw new InFileNotFoundException();
  }
  try {
    OS.rmdir(outDir);
  }
 catch (  BrutException ex) {
    throw new AndrolibException(ex);
  }
  outDir.mkdirs();
  if (hasSources()) {
switch (mDecodeSources) {
case DECODE_SOURCES_NONE:
      mAndrolib.decodeSourcesRaw(mApkFile,outDir,mDebug);
    break;
case DECODE_SOURCES_SMALI:
  mAndrolib.decodeSourcesSmali(mApkFile,outDir,mDebug,mBakDeb);
break;
case DECODE_SOURCES_JAVA:
mAndrolib.decodeSourcesJava(mApkFile,outDir,mDebug);
break;
}
}
if (hasResources()) {
JarFile jf=new JarFile(mApkFile.getAbsoluteFile());
Enumeration<?> e=jf.entries();
while (e.hasMoreElements()) {
JarEntry je=(JarEntry)e.nextElement();
if (je.getName().equalsIgnoreCase("String_Node_Str")) {
setCompressionType(je.getMethod());
continue;
}
}
jf.close();
switch (mDecodeResources) {
case DECODE_RESOURCES_NONE:
mAndrolib.decodeResourcesRaw(mApkFile,outDir);
break;
case DECODE_RESOURCES_FULL:
mAndrolib.decodeResourcesFull(mApkFile,outDir,getResTable());
break;
}
}
 else {
if (hasManifest()) {
switch (mDecodeResources) {
case DECODE_RESOURCES_NONE:
mAndrolib.decodeManifestRaw(mApkFile,outDir);
break;
case DECODE_RESOURCES_FULL:
mAndrolib.decodeManifestFull(mApkFile,outDir,getResTable());
break;
}
}
}
mAndrolib.decodeRawFiles(mApkFile,outDir);
writeMetaFile();
}
Program: 53415
Project: 53415
Buggy source:
private void writeMetaFile() throws AndrolibException {
  Map<String,Object> meta=new LinkedHashMap<String,Object>();
  meta.put("String_Node_Str",Androlib.getVersion());
  meta.put("String_Node_Str",mApkFile.getName());
  if (mDecodeResources != DECODE_RESOURCES_NONE && (hasManifest() || hasResources())) {
    meta.put("String_Node_Str",Boolean.valueOf(mAndrolib.isFrameworkApk(getResTable())));
    putUsesFramework(meta);
    putSdkInfo(meta);
    putPackageInfo(meta);
  }
  mAndrolib.writeMetaFile(mOutDir,meta);
}

Fixed version (ground truth):
private void writeMetaFile() throws AndrolibException {
  Map<String,Object> meta=new LinkedHashMap<String,Object>();
  meta.put("String_Node_Str",Androlib.getVersion());
  meta.put("String_Node_Str",mApkFile.getName());
  if (mDecodeResources != DECODE_RESOURCES_NONE && (hasManifest() || hasResources())) {
    meta.put("String_Node_Str",Boolean.valueOf(mAndrolib.isFrameworkApk(getResTable())));
    putUsesFramework(meta);
    putSdkInfo(meta);
    putPackageInfo(meta);
    putCompressionInfo(meta);
  }
  mAndrolib.writeMetaFile(mOutDir,meta);
}
Program: 53417
Project: 53417
Buggy source:
@BeforeClass public static void beforeClass() throws BrutException {
  sTmpDir=new ExtFile(OS.createTempDirectory());
  sTestOrigDir=new ExtFile(sTmpDir,"String_Node_Str");
  sTestNewDir=new ExtFile(sTmpDir,"String_Node_Str");
  File testApk=new File(sTmpDir,"String_Node_Str");
  LOGGER.info("String_Node_Str");
  TestUtils.copyResourceDir(BuildAndDecodeTest.class,"String_Node_Str",sTestOrigDir);
  LOGGER.info("String_Node_Str");
  ExtFile blank=null;
  new Androlib().build(sTestOrigDir,testApk,BuildAndDecodeTest.returnStock(),blank,"String_Node_Str");
  LOGGER.info("String_Node_Str");
  ApkDecoder apkDecoder=new ApkDecoder(testApk);
  apkDecoder.setOutDir(sTestNewDir);
  apkDecoder.decode();
}

Fixed version (ground truth):
@BeforeClass public static void beforeClass() throws BrutException, IOException {
  sTmpDir=new ExtFile(OS.createTempDirectory());
  sTestOrigDir=new ExtFile(sTmpDir,"String_Node_Str");
  sTestNewDir=new ExtFile(sTmpDir,"String_Node_Str");
  File testApk=new File(sTmpDir,"String_Node_Str");
  LOGGER.info("String_Node_Str");
  TestUtils.copyResourceDir(BuildAndDecodeTest.class,"String_Node_Str",sTestOrigDir);
  LOGGER.info("String_Node_Str");
  ExtFile blank=null;
  new Androlib().build(sTestOrigDir,testApk,BuildAndDecodeTest.returnStock(),blank,"String_Node_Str");
  LOGGER.info("String_Node_Str");
  ApkDecoder apkDecoder=new ApkDecoder(testApk);
  apkDecoder.setOutDir(sTestNewDir);
  apkDecoder.decode();
}
Program: 53418
Project: 53418
Buggy source:
public void buildApk(File appDir,File outApk,HashMap<String,Boolean> flags) throws AndrolibException {
  LOGGER.info("String_Node_Str");
  if (outApk.exists()) {
    outApk.delete();
  }
 else {
    File outDir=outApk.getParentFile();
    if (outDir != null && !outDir.exists()) {
      outDir.mkdirs();
    }
  }
  File assetDir=new File(appDir,"String_Node_Str");
  if (!assetDir.exists()) {
    assetDir=null;
  }
  mAndRes.aaptPackage(outApk,null,null,new File(appDir,APK_DIRNAME),assetDir,null,flags);
  if (flags.get("String_Node_Str")) {
    try {
      LOGGER.info("String_Node_Str");
      ZipFile editOrig=new ZipFile(mOrigApkFile.getAbsoluteFile());
      ZipParameters parameters=new ZipParameters();
      parameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
      parameters.setCompressionLevel(0);
      parameters.setIncludeRootFolder(true);
      parameters.setRootFolderInZip("String_Node_Str");
      editOrig.addFolder(new File(appDir,APK_DIRNAME + "String_Node_Str").getAbsolutePath(),parameters);
      if (assetDir.exists()) {
      }
      parameters.setFileNameInZip("String_Node_Str");
    }
 catch (    ZipException e) {
      LOGGER.warning(e.getMessage());
    }
  }
}

Fixed version (ground truth):
public void buildApk(File appDir,File outApk,HashMap<String,Boolean> flags) throws AndrolibException {
  LOGGER.info("String_Node_Str");
  if (outApk.exists()) {
    outApk.delete();
  }
 else {
    File outDir=outApk.getParentFile();
    if (outDir != null && !outDir.exists()) {
      outDir.mkdirs();
    }
  }
  File assetDir=new File(appDir,"String_Node_Str");
  if (!assetDir.exists()) {
    assetDir=null;
  }
  mAndRes.aaptPackage(outApk,null,null,new File(appDir,APK_DIRNAME),assetDir,null,flags);
  if (flags.get("String_Node_Str")) {
    try {
      LOGGER.info("String_Node_Str");
      ZipFile editOrig=new ZipFile(mOrigApkFile.getAbsoluteFile());
      ZipParameters parameters=new ZipParameters();
      parameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
      parameters.setCompressionLevel(0);
      parameters.setIncludeRootFolder(true);
      parameters.setRootFolderInZip("String_Node_Str");
      editOrig.addFolder(new File(appDir,APK_DIRNAME + "String_Node_Str").getAbsolutePath(),parameters);
      if (assetDir != null) {
      }
      parameters.setFileNameInZip("String_Node_Str");
    }
 catch (    ZipException ex) {
      throw new AndrolibException(ex);
    }
  }
}
Program: 53419
Project: 53419
Buggy source:
private void decode() throws AndrolibException {
  try {
    baksmali.disassembleDexFile(mApkFile.getAbsolutePath(),new DexFile(mApkFile),false,mOutDir.getAbsolutePath(),null,null,null,false,true,true,true,false,false,mDebug ? main.FULLMERGE : 0,false,mDebug ? true : false,null);
  }
 catch (  IOException ex) {
    throw new AndrolibException(ex);
  }
}

Fixed version (ground truth):
private void decode() throws AndrolibException {
  if (mDebug) {
    ClassPath.dontLoadClassPath=true;
  }
  try {
    baksmali.disassembleDexFile(mApkFile.getAbsolutePath(),new DexFile(mApkFile),false,mOutDir.getAbsolutePath(),null,null,null,false,true,true,true,false,false,mDebug ? main.DIFFPRE : 0,false,false,null);
  }
 catch (  IOException ex) {
    throw new AndrolibException(ex);
  }
}
Program: 53420
Project: 53420
Buggy source:
public String getType() throws AndrolibException {
  if (mItems.length == 0) {
    return null;
  }
  String type=mItems[0].getType();
  if (!"String_Node_Str".equals(type) && !"String_Node_Str".equals(type)) {
    return null;
  }
  for (int i=1; i < mItems.length; i++) {
    if (StringUtils.containsIgnoreCase("String_Node_Str",mItems[i].encodeAsResXmlItemValue()) || mItems[i].getType().equalsIgnoreCase("String_Node_Str")) {
      return "String_Node_Str";
    }
    if (!type.equals(mItems[i].getType())) {
      return null;
    }
  }
  return type;
}

Fixed version (ground truth):
public String getType() throws AndrolibException {
  if (mItems.length == 0) {
    return null;
  }
  String type=mItems[0].getType();
  if (!"String_Node_Str".equals(type) && !"String_Node_Str".equals(type)) {
    return null;
  }
  for (int i=1; i < mItems.length; i++) {
    if (!type.equals(mItems[i].getType())) {
      return null;
    }
  }
  return type;
}
Program: 53421
Project: 53421
Buggy source:
@Test public void valuesArraysTest() throws BrutException {
  compareValuesFiles("String_Node_Str");
}

Fixed version (ground truth):
@Test public void valuesArraysTest() throws BrutException {
  compareValuesFiles("String_Node_Str");
  compareValuesFiles("String_Node_Str");
}
Program: 53422
Project: 53422
Buggy source:
private static List<Integer> findNonPositionalSubstitutions(String str,int max){
  int pos=0;
  int count=0;
  int length=str.length();
  List<Integer> ret=new ArrayList<Integer>();
  while ((pos=str.indexOf('%',pos)) != -1) {
    if (pos + 1 == length) {
      break;
    }
    char c=str.charAt(pos + 1);
    if (c >= 'a' && c <= 'z') {
      ret.add(pos);
      if (max != -1 && ++count >= max) {
        break;
      }
    }
    pos+=2;
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * It searches for "%", but not "%%" nor "%(\d)+\$"
 */
private static List<Integer> findNonPositionalSubstitutions(String str,int max){
  int pos=0;
  int pos2=0;
  int count=0;
  int length=str.length();
  List<Integer> ret=new ArrayList<Integer>();
  while ((pos2=(pos=str.indexOf('%',pos2)) + 1) != 0) {
    if (pos2 == length) {
      break;
    }
    char c=str.charAt(pos2++);
    if (c == '%') {
      continue;
    }
    if (c >= '0' && c <= '9' && pos2 < length) {
      do {
        c=str.charAt(pos2++);
      }
 while (c >= '0' && c <= '9' && pos2 < length);
      if (c == '$') {
        continue;
      }
    }
    ret.add(pos);
    if (max != -1 && ++count >= max) {
      break;
    }
  }
  return ret;
}
Program: 53423
Project: 53423
Buggy source:
public void serializeToResValuesXml(XmlSerializer serializer,ResResource res) throws IOException, AndrolibException {
  String type=res.getResSpec().getType().getName();
  boolean item=!"String_Node_Str".equals(mType) && !type.equals(mType);
  String tagName=item ? "String_Node_Str" : type;
  serializer.startTag(null,tagName);
  if (item) {
    serializer.attribute(null,"String_Node_Str",type);
  }
  serializer.attribute(null,"String_Node_Str",res.getResSpec().getName());
  serializeExtraXmlAttrs(serializer,res);
  String body=encodeAsResXmlValue();
  if (!body.isEmpty()) {
    serializer.ignorableWhitespace(body);
  }
  serializer.endTag(null,tagName);
}

Fixed version (ground truth):
public void serializeToResValuesXml(XmlSerializer serializer,ResResource res) throws IOException, AndrolibException {
  String type=res.getResSpec().getType().getName();
  boolean item=!"String_Node_Str".equals(mType) && !type.equals(mType);
  String body=encodeAsResXmlValue();
  if (body.contains("String_Node_Str")) {
    item=true;
  }
  String tagName=item ? "String_Node_Str" : type;
  serializer.startTag(null,tagName);
  if (item) {
    serializer.attribute(null,"String_Node_Str",type);
  }
  serializer.attribute(null,"String_Node_Str",res.getResSpec().getName());
  serializeExtraXmlAttrs(serializer,res);
  if (!body.isEmpty()) {
    serializer.ignorableWhitespace(body);
  }
  serializer.endTag(null,tagName);
}
Program: 53426
Project: 53426
Buggy source:
private static List<Integer> findNonPositionalSubstitutions(String str,int max){
  int pos=0;
  int count=0;
  List<Integer> ret=new ArrayList<Integer>();
  while ((pos=str.indexOf('%',pos)) != -1) {
    if (str.charAt(pos + 1) != '%') {
      ret.add(pos);
      if (max != -1 && ++count >= max) {
        break;
      }
    }
    pos+=2;
  }
  return ret;
}

Fixed version (ground truth):
private static List<Integer> findNonPositionalSubstitutions(String str,int max){
  int pos=0;
  int count=0;
  int length=str.length();
  List<Integer> ret=new ArrayList<Integer>();
  while ((pos=str.indexOf('%',pos)) != -1) {
    if (pos + 1 == length) {
      break;
    }
    if (str.charAt(pos + 1) != '%') {
      ret.add(pos);
      if (max != -1 && ++count >= max) {
        break;
      }
    }
    pos+=2;
  }
  return ret;
}
Program: 53427
Project: 53427
Buggy source:
private void addMissingResSpecs() throws AndrolibException {
  int resId=mResId & 0xffff0000;
  for (int i=0; i < mMissingResSpecs.length; i++) {
    if (!mMissingResSpecs[i]) {
      continue;
    }
    ResResSpec spec=new ResResSpec(new ResID(resId | i),String.format("String_Node_Str",i),mPkg,mType);
    mPkg.addResSpec(spec);
    mType.addResSpec(spec);
    ResValue value=new ResBoolValue(false);
    ResResource res=new ResResource(mPkg.getConfig(new ResConfigFlags()),spec,value);
    mPkg.addResource(res);
    mConfig.addResource(res);
    spec.addResource(res);
  }
}

Fixed version (ground truth):
private void addMissingResSpecs() throws AndrolibException {
  int resId=mResId & 0xffff0000;
  for (int i=0; i < mMissingResSpecs.length; i++) {
    if (!mMissingResSpecs[i]) {
      continue;
    }
    ResResSpec spec=new ResResSpec(new ResID(resId | i),String.format("String_Node_Str",i),mPkg,mType);
    mPkg.addResSpec(spec);
    mType.addResSpec(spec);
    ResValue value=new ResBoolValue(false);
    ResResource res=new ResResource(mPkg.getOrCreateConfig(new ResConfigFlags()),spec,value);
    mPkg.addResource(res);
    mConfig.addResource(res);
    spec.addResource(res);
  }
}
Program: 53428
Project: 53428
Buggy source:
private void find9patchChunk(DataInput di) throws AndrolibException, IOException {
  di.skipBytes(8);
  while (true) {
    int size;
    try {
      size=di.readInt();
    }
 catch (    IOException ex) {
      throw new AndrolibException("String_Node_Str",ex);
    }
    if (di.readInt() == NP_CHUNK_TYPE) {
      return;
    }
    di.skipBytes(size + 4);
  }
}

Fixed version (ground truth):
private void find9patchChunk(DataInput di) throws AndrolibException, IOException {
  di.skipBytes(8);
  while (true) {
    int size;
    try {
      size=di.readInt();
    }
 catch (    IOException ex) {
      throw new CantFind9PatchChunk("String_Node_Str",ex);
    }
    if (di.readInt() == NP_CHUNK_TYPE) {
      return;
    }
    di.skipBytes(size + 4);
  }
}
Program: 53429
Project: 53429
Buggy source:
private File getFrameworkApk(int id,String frameTag) throws AndrolibException {
  File dir=getFrameworkDir();
  File apk=new File(dir,String.valueOf(id) + '-' + frameTag+ "String_Node_Str");
  if (apk.exists()) {
    return apk;
  }
  apk=new File(dir,String.valueOf(id) + "String_Node_Str");
  if (apk.exists()) {
    return apk;
  }
  if (id == 1) {
    InputStream in=null;
    OutputStream out=null;
    try {
      in=AndrolibResources.class.getResourceAsStream("String_Node_Str");
      out=new FileOutputStream(apk);
      IOUtils.copy(in,out);
      return apk;
    }
 catch (    IOException ex) {
      throw new AndrolibException(ex);
    }
 finally {
      if (in != null) {
        try {
          in.close();
        }
 catch (        IOException ex) {
        }
      }
      if (out != null) {
        try {
          out.close();
        }
 catch (        IOException ex) {
        }
      }
    }
  }
  throw new CantFindFrameworkResException(id);
}

Fixed version (ground truth):
private File getFrameworkApk(int id,String frameTag) throws AndrolibException {
  File dir=getFrameworkDir();
  File apk;
  if (frameTag != null) {
    apk=new File(dir,String.valueOf(id) + '-' + frameTag+ "String_Node_Str");
    if (apk.exists()) {
      return apk;
    }
  }
  apk=new File(dir,String.valueOf(id) + "String_Node_Str");
  if (apk.exists()) {
    return apk;
  }
  if (id == 1) {
    InputStream in=null;
    OutputStream out=null;
    try {
      in=AndrolibResources.class.getResourceAsStream("String_Node_Str");
      out=new FileOutputStream(apk);
      IOUtils.copy(in,out);
      return apk;
    }
 catch (    IOException ex) {
      throw new AndrolibException(ex);
    }
 finally {
      if (in != null) {
        try {
          in.close();
        }
 catch (        IOException ex) {
        }
      }
      if (out != null) {
        try {
          out.close();
        }
 catch (        IOException ex) {
        }
      }
    }
  }
  throw new CantFindFrameworkResException(id);
}
Program: 53430
Project: 53430
Buggy source:
public boolean buildResourcesFull(File appDir,boolean forceBuildAll,boolean framework,Map<String,Object> usesFramework) throws AndrolibException {
  try {
    if (!new File(appDir,"String_Node_Str").exists()) {
      return false;
    }
    if (!forceBuildAll) {
      LOGGER.info("String_Node_Str");
    }
    File apkDir=new File(appDir,APK_DIRNAME);
    if (forceBuildAll || isModified(newFiles(APP_RESOURCES_FILENAMES,appDir),newFiles(APK_RESOURCES_FILENAMES,apkDir))) {
      LOGGER.info("String_Node_Str");
      File apkFile=File.createTempFile("String_Node_Str",null);
      apkFile.delete();
      File ninePatch=new File(appDir,"String_Node_Str");
      if (!ninePatch.exists()) {
        ninePatch=null;
      }
      mAndRes.aaptPackage(apkFile,new File(appDir,"String_Node_Str"),new File(appDir,"String_Node_Str"),ninePatch,null,parseUsesFramework(usesFramework),false,framework);
      new ExtFile(apkFile).getDirectory().copyToDir(apkDir,APK_RESOURCES_FILENAMES);
    }
    return true;
  }
 catch (  IOException ex) {
    throw new AndrolibException(ex);
  }
catch (  DirectoryException ex) {
    throw new AndrolibException(ex);
  }
}

Fixed version (ground truth):
public boolean buildResourcesFull(File appDir,boolean forceBuildAll,boolean framework,Map<String,Object> usesFramework) throws AndrolibException {
  try {
    if (!new File(appDir,"String_Node_Str").exists()) {
      return false;
    }
    if (!forceBuildAll) {
      LOGGER.info("String_Node_Str");
    }
    File apkDir=new File(appDir,APK_DIRNAME);
    if (forceBuildAll || isModified(newFiles(APP_RESOURCES_FILENAMES,appDir),newFiles(APK_RESOURCES_FILENAMES,apkDir))) {
      LOGGER.info("String_Node_Str");
      File apkFile=File.createTempFile("String_Node_Str",null);
      apkFile.delete();
      File ninePatch=new File(appDir,"String_Node_Str");
      if (!ninePatch.exists()) {
        ninePatch=null;
      }
      mAndRes.aaptPackage(apkFile,new File(appDir,"String_Node_Str"),new File(appDir,"String_Node_Str"),ninePatch,null,parseUsesFramework(usesFramework),false,framework);
      Directory tmpDir=new ExtFile(apkFile).getDirectory();
      tmpDir.copyToDir(apkDir,tmpDir.containsDir("String_Node_Str") ? APK_RESOURCES_FILENAMES : APK_RESOURCES_WITHOUT_RES_FILENAMES);
    }
    return true;
  }
 catch (  IOException ex) {
    throw new AndrolibException(ex);
  }
catch (  DirectoryException ex) {
    throw new AndrolibException(ex);
  }
}
Program: 53431
Project: 53431
Buggy source:
public void decode(ResTable resTable,ExtFile apkFile,File outDir) throws AndrolibException {
  Duo<ResFileDecoder,ResAttrDecoder> duo=getResFileDecoder();
  ResFileDecoder fileDecoder=duo.m1;
  ResAttrDecoder attrDecoder=duo.m2;
  attrDecoder.setCurrentPackage(resTable.listMainPackages().iterator().next());
  Directory in, out;
  try {
    in=apkFile.getDirectory();
    out=new FileDirectory(outDir);
    fileDecoder.decode(in,"String_Node_Str",out,"String_Node_Str","String_Node_Str");
    in=in.getDir("String_Node_Str");
    out=out.createDir("String_Node_Str");
  }
 catch (  DirectoryException ex) {
    throw new AndrolibException(ex);
  }
  ExtMXSerializer xmlSerializer=getResXmlSerializer();
  for (  ResPackage pkg : resTable.listMainPackages()) {
    attrDecoder.setCurrentPackage(pkg);
    for (    ResResource res : pkg.listFiles()) {
      fileDecoder.decode(res,in,out);
    }
    for (    ResValuesFile valuesFile : pkg.listValuesFiles()) {
      generateValuesFile(valuesFile,out,xmlSerializer);
    }
    generatePublicXml(pkg,out,xmlSerializer);
  }
}

Fixed version (ground truth):
public void decode(ResTable resTable,ExtFile apkFile,File outDir) throws AndrolibException {
  Duo<ResFileDecoder,ResAttrDecoder> duo=getResFileDecoder();
  ResFileDecoder fileDecoder=duo.m1;
  ResAttrDecoder attrDecoder=duo.m2;
  attrDecoder.setCurrentPackage(resTable.listMainPackages().iterator().next());
  Directory inApk, in=null, out;
  try {
    inApk=apkFile.getDirectory();
    out=new FileDirectory(outDir);
    fileDecoder.decode(inApk,"String_Node_Str",out,"String_Node_Str","String_Node_Str");
    if (inApk.containsDir("String_Node_Str")) {
      in=inApk.getDir("String_Node_Str");
    }
    out=out.createDir("String_Node_Str");
  }
 catch (  DirectoryException ex) {
    throw new AndrolibException(ex);
  }
  ExtMXSerializer xmlSerializer=getResXmlSerializer();
  for (  ResPackage pkg : resTable.listMainPackages()) {
    attrDecoder.setCurrentPackage(pkg);
    for (    ResResource res : pkg.listFiles()) {
      fileDecoder.decode(res,in,out);
    }
    for (    ResValuesFile valuesFile : pkg.listValuesFiles()) {
      generateValuesFile(valuesFile,out,xmlSerializer);
    }
    generatePublicXml(pkg,out,xmlSerializer);
  }
}
Program: 53432
Project: 53432
Buggy source:
private void inject() throws AndrolibException {
  String definition=nextAndAppend();
  if (definition.contains("String_Node_Str")) {
    nextAndAppend();
    return;
  }
  injectParameters(definition);
  boolean end=false;
  while (!end) {
    end=step();
  }
}

Fixed version (ground truth):
private void inject() throws AndrolibException {
  String definition=nextAndAppend();
  if (definition.contains("String_Node_Str") || definition.contains("String_Node_Str")) {
    nextAndAppend();
    return;
  }
  injectParameters(definition);
  boolean end=false;
  while (!end) {
    end=step();
  }
}
Program: 53433
Project: 53433
Buggy source:
public static String escapeForResXml(String value){
  if (value.isEmpty()) {
    return value;
  }
  StringBuilder out=new StringBuilder(value.length() + 10);
  char[] chars=value.toCharArray();
switch (chars[0]) {
case '@':
case '#':
case '?':
    out.append('\\');
}
boolean space=true;
for (int i=0; i < chars.length; i++) {
  char c=chars[i];
  if (c == ' ') {
    if (space) {
      out.append("String_Node_Str");
    }
 else {
      out.append(c);
      space=true;
    }
    continue;
  }
  space=false;
switch (c) {
case '\\':
case '\'':
case '"':
    out.append('\\');
  break;
case '\n':
out.append("String_Node_Str");
continue;
}
out.append(c);
}
if (space) {
out.deleteCharAt(out.length() - 1);
out.append("String_Node_Str");
}
return out.toString();
}

Fixed version (ground truth):
public static String escapeForResXml(String value){
  if (value.isEmpty()) {
    return value;
  }
  StringBuilder out=new StringBuilder(value.length() + 10);
  char[] chars=value.toCharArray();
switch (chars[0]) {
case '@':
case '#':
case '?':
    out.append('\\');
}
boolean space=true;
for (int i=0; i < chars.length; i++) {
  char c=chars[i];
  if (c == ' ') {
    if (space) {
      out.append("String_Node_Str");
    }
 else {
      out.append(c);
      space=true;
    }
    continue;
  }
  space=false;
switch (c) {
case '\\':
case '\'':
case '"':
    out.append('\\');
  break;
case '\n':
out.append("String_Node_Str");
continue;
}
out.append(c);
}
if (space && out.charAt(out.length() - 1) == ' ') {
out.deleteCharAt(out.length() - 1);
out.append("String_Node_Str");
}
return out.toString();
}