Program: 21049
Project: 21049
Buggy source:
public int trainCaptcha(final File captchafile,int letterNum){
  if (!captchafile.exists()) {
    if (Utilities.isLoggerActive()) {
      logger.severe(captchafile.getAbsolutePath() + "String_Node_Str");
    }
    return -1;
  }
  if (isShowDebugGui()) {
    destroyScrollPaneWindows();
  }
  final String captchaHash=JDHash.getMD5(captchafile);
  if (isCaptchaInMTH(captchaHash)) {
    if (Utilities.isLoggerActive()) {
      logger.fine("String_Node_Str" + captchafile);
    }
    return -1;
  }
  Image captchaImage=Utilities.loadImage(captchafile);
  final Captcha captcha=createCaptcha(captchaImage);
  if (captcha == null)   return -1;
  String code=null;
  new GuiRunnable<Object>(){
    public Object runSave(){
      if (f != null) {
        f.dispose();
      }
      f=new JDialog(DummyFrame.getDialogParent());
      f.setLocation(500,10);
      f.setLayout(new GridBagLayout());
      f.add(new JLabel("String_Node_Str" + captchafile.getName()),Utilities.getGBC(0,0,10,1));
      f.add(new ImageComponent(captcha.getImage()),Utilities.getGBC(0,1,10,1));
      f.setSize(1400,800);
      f.pack();
      f.setVisible(true);
      return null;
    }
  }
.waitForEDT();
  final String guess=checkCaptcha(captchafile,captcha);
  final Letter[] letters=captcha.getLetters(letterNum);
  if (letters == null) {
    File file=getResourceFile("String_Node_Str" + System.currentTimeMillis() + "String_Node_Str"+ captchafile.getName());
    file.getParentFile().mkdirs();
    captchafile.renameTo(file);
    if (Utilities.isLoggerActive()) {
      logger.severe("String_Node_Str");
    }
    return -1;
  }
class MyRunnable implements Runnable {
    public String code=null;
    public int ret=0;
    public void run(){
      if (getCodeFromFileName(captchafile.getName()) == null) {
        code=new GuiRunnable<String>(){
          public String runSave(){
            return JOptionPane.showInputDialog("String_Node_Str" + guess,guess);
          }
        }
.getReturnValue();
        if (code != null && code.equals(guess)) {
          code="String_Node_Str";
        }
 else         if (code == null) {
          if (new GuiRunnable<Boolean>(){
            public Boolean runSave(){
              return JOptionPane.showConfirmDialog(new JFrame(),"String_Node_Str") == JOptionPane.OK_OPTION;
            }
          }
.getReturnValue()) {
            ret=-2;
          }
        }
      }
 else {
        code=getCodeFromFileName(captchafile.getName());
        if (Utilities.isLoggerActive()) {
          logger.warning("String_Node_Str" + captchaHash + "String_Node_Str"+ code);
        }
      }
synchronized (this) {
        this.notify();
      }
    }
  }
  MyRunnable run=new MyRunnable();
  Thread inpThread=new Thread(run);
  inpThread.start();
  new GuiRunnable<Object>(){
    public Object runSave(){
      f.add(new JLabel("String_Node_Str"),Utilities.getGBC(0,3,10,1));
      f.add(new ImageComponent(captcha.getImageWithGaps(1)),Utilities.getGBC(0,4,10,1));
      f.add(new JLabel("String_Node_Str"),Utilities.getGBC(0,5,10,1));
      for (int i=0; i < letters.length; i++) {
        f.add(new ImageComponent(letters[i].getImage((int)Math.ceil(jas.getDouble("String_Node_Str")))),Utilities.getGBC(i * 2 + 1,6,1,1));
        JLabel jl=new JLabel("String_Node_Str");
        jl.setForeground(Color.RED);
        f.add(jl,Utilities.getGBC(i * 2 + 2,6,1,1));
      }
      f.pack();
      return null;
    }
  }
.waitForEDT();
  final LetterComperator[] lcs=captcha.getLetterComperators();
  if (lcs == null) {
    File file=getResourceFile("String_Node_Str" + System.currentTimeMillis() + "String_Node_Str"+ captchafile.getName());
    file.getParentFile().mkdirs();
    captchafile.renameTo(file);
    if (Utilities.isLoggerActive()) {
      logger.severe("String_Node_Str");
    }
    return -1;
  }
  if (lcs.length != letters.length) {
    logger.severe("String_Node_Str" + lcs.length + "String_Node_Str"+ letters.length);
  }
  new GuiRunnable<Object>(){
    public Object runSave(){
      if (guess != null) {
        f.add(new JLabel("String_Node_Str"),Utilities.getGBC(0,3,10,1));
        f.add(new ImageComponent(captcha.getImageWithGaps(1)),Utilities.getGBC(0,4,10,1));
        f.add(new JLabel("String_Node_Str"),Utilities.getGBC(0,5,10,1));
        for (int i=0; i < letters.length; i++) {
          f.add(new ImageComponent(letters[i].getImage((int)Math.ceil(jas.getDouble("String_Node_Str")))),Utilities.getGBC(i * 2 + 1,6,1,1));
          JLabel jl=new JLabel("String_Node_Str");
          jl.setForeground(Color.RED);
          f.add(jl,Utilities.getGBC(i * 2 + 2,6,1,1));
        }
        f.pack();
        for (int i=0; i < lcs.length; i++) {
          if (lcs[i] != null && lcs[i].getB() != null) {
            f.add(new ImageComponent(lcs[i].getB().getImage((int)Math.ceil(jas.getDouble("String_Node_Str")))),Utilities.getGBC(i * 2 + 1,8,1,1));
          }
 else {
            f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i * 2 + 1,8,1,1));
          }
          JLabel jl=new JLabel("String_Node_Str");
          jl.setForeground(Color.RED);
          f.add(jl,Utilities.getGBC(i * 2 + 2,6,1,1));
          if (lcs[i] != null && lcs[i].getB() != null) {
            f.add(new JLabel("String_Node_Str" + lcs[i].getDecodedValue()),Utilities.getGBC(i * 2 + 1,9,1,1));
          }
 else {
            f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i * 2 + 1,9,1,1));
          }
          if (lcs[i] != null && lcs[i].getB() != null) {
            f.add(new JLabel("String_Node_Str" + Math.round(10 * lcs[i].getValityPercent()) / 10.0),Utilities.getGBC(i * 2 + 1,10,1,1));
          }
 else {
            f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i * 2 + 1,10,1,1));
          }
        }
        f.pack();
      }
 else {
        if (Utilities.isLoggerActive()) {
          logger.warning("String_Node_Str");
        }
      }
      f.add(new JLabel("String_Node_Str"),Utilities.getGBC(0,11,10,1));
      f.add(new ImageComponent(captcha.getImage()),Utilities.getGBC(0,12,10,1));
      f.pack();
      return null;
    }
  }
.waitForEDT();
  if (Utilities.isLoggerActive()) {
    logger.info("String_Node_Str" + guess + "String_Node_Str"+ captcha.getValityPercent());
  }
  if (inpThread.isAlive()) {
synchronized (run) {
      try {
        run.wait();
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  if (run.ret == -2)   return -2;
  code=run.code;
  if (code == null) {
    File file=getResourceFile("String_Node_Str" + System.currentTimeMillis() + "String_Node_Str"+ captchafile.getName());
    file.getParentFile().mkdirs();
    captchafile.renameTo(file);
    if (Utilities.isLoggerActive()) {
      logger.severe("String_Node_Str");
    }
    return -1;
  }
  if (code.length() == 0) {
    code=guess;
  }
  if (code.length() != letters.length) {
    File file=getResourceFile("String_Node_Str" + System.currentTimeMillis() + "String_Node_Str"+ captchafile.getName());
    file.getParentFile().mkdirs();
    captchafile.renameTo(file);
    if (Utilities.isLoggerActive()) {
      logger.severe("String_Node_Str");
    }
    return -1;
  }
  if (code.indexOf("String_Node_Str") < 0) {
    String[] oldName=captchafile.getName().split("String_Node_Str");
    String ext=oldName[oldName.length - 1];
    String newName=captchafile.getParentFile().getAbsolutePath() + "String_Node_Str" + getMethodDirName()+ "String_Node_Str"+ code+ "String_Node_Str"+ ext;
    captchafile.renameTo(new File(newName));
  }
  int ret=0;
  for (int j=0; j < letters.length; j++) {
    final int i=j;
    if (!code.substring(i,i + 1).equals("String_Node_Str")) {
      if (guess != null && code.length() > i && guess.length() > i && code.substring(i,i + 1).equals(guess.substring(i,i + 1))) {
        ret++;
        if (lcs[i] != null) {
          lcs[i].getB().markGood();
        }
        if (lcs[i].getValityPercent() > 50) {
          letters[i].setOwner(this);
          letters[i].setSourcehash(captchaHash);
          letters[i].setDecodedValue(code.substring(i,i + 1));
          new Thread(new Runnable(){
            public void run(){
              final BasicWindow bws=new GuiRunnable<BasicWindow>(){
                public BasicWindow runSave(){
                  return BasicWindow.showImage(letters[i].getImage(2),"String_Node_Str" + letters[i].getDecodedValue());
                }
              }
.getReturnValue();
              try {
                Thread.sleep(1000);
              }
 catch (              InterruptedException e) {
                e.printStackTrace();
              }
              new GuiRunnable<Object>(){
                public Object runSave(){
                  bws.dispose();
                  return null;
                }
              }
.waitForEDT();
            }
          }
).start();
          letterDB.add(letters[i]);
        }
        if (!jas.getBoolean("String_Node_Str")) {
          letters[i].setOwner(this);
          letters[i].setSourcehash(captchaHash);
          letters[i].setDecodedValue(code.substring(i,i + 1));
          letterDB.add(letters[i]);
          new GuiRunnable<Object>(){
            public Object runSave(){
              f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i + 1,13,1,1));
              return null;
            }
          }
.waitForEDT();
        }
 else {
          new GuiRunnable<Object>(){
            public Object runSave(){
              f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i + 1,13,1,1));
              return null;
            }
          }
.waitForEDT();
        }
        new GuiRunnable<Object>(){
          public Object runSave(){
            f.pack();
            return null;
          }
        }
.waitForEDT();
      }
 else {
        if (Utilities.isLoggerActive()) {
          logger.info(letterDB + "String_Node_Str");
        }
        if (lcs != null && lcs[i] != null && letterDB.size() > 30 && lcs[i] != null && lcs[i].getB() != null) {
          lcs[i].getB().markBad();
        }
        letters[i].setOwner(this);
        letters[i].setSourcehash(captchaHash);
        letters[i].setDecodedValue(code.substring(i,i + 1));
        letterDB.add(letters[i]);
        new GuiRunnable<Object>(){
          public Object runSave(){
            BasicWindow.showImage(letters[i].getImage(2),"String_Node_Str" + letters[i].getDecodedValue());
            f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i + 1,13,1,1));
            f.pack();
            return null;
          }
        }
.waitForEDT();
      }
    }
 else {
      new GuiRunnable<Object>(){
        public Object runSave(){
          f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i + 1,13,1,1));
          f.pack();
          return null;
        }
      }
.waitForEDT();
    }
  }
  sortLetterDB();
  new Thread(new Runnable(){
    public void run(){
      saveMTHFile();
    }
  }
).start();
  return ret;
}

Fixed version (ground truth):
public int trainCaptcha(final File captchafile,int letterNum){
  if (!captchafile.exists()) {
    if (Utilities.isLoggerActive()) {
      logger.severe(captchafile.getAbsolutePath() + "String_Node_Str");
    }
    return -1;
  }
  if (isShowDebugGui()) {
    destroyScrollPaneWindows();
  }
  final String captchaHash=JDHash.getMD5(captchafile);
  if (isCaptchaInMTH(captchaHash)) {
    if (Utilities.isLoggerActive()) {
      logger.fine("String_Node_Str" + captchafile);
    }
    return -1;
  }
  Image captchaImage=Utilities.loadImage(captchafile);
  final Captcha captcha=createCaptcha(captchaImage);
  if (captcha == null)   return -1;
  String code=null;
  new GuiRunnable<Object>(){
    public Object runSave(){
      if (f != null) {
        f.dispose();
      }
      f=new JDialog(DummyFrame.getDialogParent());
      f.setLocation(500,10);
      f.setLayout(new GridBagLayout());
      f.add(new JLabel("String_Node_Str" + captchafile.getName()),Utilities.getGBC(0,0,10,1));
      f.add(new ImageComponent(captcha.getImage()),Utilities.getGBC(0,1,10,1));
      f.setSize(1400,800);
      f.pack();
      f.setVisible(true);
      return null;
    }
  }
.waitForEDT();
  final String guess=checkCaptcha(captchafile,captcha);
  final Letter[] letters=captcha.getLetters(letterNum);
  if (letters == null) {
    File file=getResourceFile("String_Node_Str" + System.currentTimeMillis() + "String_Node_Str"+ captchafile.getName());
    file.getParentFile().mkdirs();
    captchafile.renameTo(file);
    if (Utilities.isLoggerActive()) {
      logger.severe("String_Node_Str");
    }
    return -1;
  }
class MyRunnable implements Runnable {
    public String code=null;
    public int ret=0;
    public void run(){
      if (getCodeFromFileName(captchafile.getName()) == null) {
        code=new GuiRunnable<String>(){
          public String runSave(){
            return JOptionPane.showInputDialog("String_Node_Str" + guess,guess);
          }
        }
.getReturnValue();
        if (code != null && code.equals(guess)) {
          code="String_Node_Str";
        }
 else         if (code == null) {
          if (new GuiRunnable<Boolean>(){
            public Boolean runSave(){
              return JOptionPane.showConfirmDialog(new JFrame(),"String_Node_Str") == JOptionPane.OK_OPTION;
            }
          }
.getReturnValue()) {
            ret=-2;
          }
        }
      }
 else {
        code=getCodeFromFileName(captchafile.getName());
        if (Utilities.isLoggerActive()) {
          logger.warning("String_Node_Str" + captchaHash + "String_Node_Str"+ code);
        }
      }
synchronized (this) {
        this.notify();
      }
    }
  }
  MyRunnable run=new MyRunnable();
  Thread inpThread=new Thread(run);
  inpThread.start();
  new GuiRunnable<Object>(){
    public Object runSave(){
      f.add(new JLabel("String_Node_Str"),Utilities.getGBC(0,3,10,1));
      f.add(new ImageComponent(captcha.getImageWithGaps(1)),Utilities.getGBC(0,4,10,1));
      f.add(new JLabel("String_Node_Str"),Utilities.getGBC(0,5,10,1));
      for (int i=0; i < letters.length; i++) {
        f.add(new ImageComponent(letters[i].getImage((int)Math.ceil(jas.getDouble("String_Node_Str")))),Utilities.getGBC(i * 2 + 1,6,1,1));
        JLabel jl=new JLabel("String_Node_Str");
        jl.setForeground(Color.RED);
        f.add(jl,Utilities.getGBC(i * 2 + 2,6,1,1));
      }
      f.pack();
      return null;
    }
  }
.waitForEDT();
  final LetterComperator[] lcs=captcha.getLetterComperators();
  if (lcs == null) {
    File file=getResourceFile("String_Node_Str" + System.currentTimeMillis() + "String_Node_Str"+ captchafile.getName());
    file.getParentFile().mkdirs();
    captchafile.renameTo(file);
    if (Utilities.isLoggerActive()) {
      logger.severe("String_Node_Str");
    }
    return -1;
  }
  if (lcs.length != letters.length) {
    logger.severe("String_Node_Str" + lcs.length + "String_Node_Str"+ letters.length);
  }
  new GuiRunnable<Object>(){
    public Object runSave(){
      if (guess != null) {
        f.add(new JLabel("String_Node_Str"),Utilities.getGBC(0,3,10,1));
        f.add(new ImageComponent(captcha.getImageWithGaps(1)),Utilities.getGBC(0,4,10,1));
        f.add(new JLabel("String_Node_Str"),Utilities.getGBC(0,5,10,1));
        for (int i=0; i < letters.length; i++) {
          f.add(new ImageComponent(letters[i].getImage((int)Math.ceil(jas.getDouble("String_Node_Str")))),Utilities.getGBC(i * 2 + 1,6,1,1));
          JLabel jl=new JLabel("String_Node_Str");
          jl.setForeground(Color.RED);
          f.add(jl,Utilities.getGBC(i * 2 + 2,6,1,1));
        }
        f.pack();
        for (int i=0; i < lcs.length; i++) {
          if (lcs[i] != null && lcs[i].getB() != null) {
            f.add(new ImageComponent(lcs[i].getB().getImage((int)Math.ceil(jas.getDouble("String_Node_Str")))),Utilities.getGBC(i * 2 + 1,8,1,1));
          }
 else {
            f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i * 2 + 1,8,1,1));
          }
          JLabel jl=new JLabel("String_Node_Str");
          jl.setForeground(Color.RED);
          f.add(jl,Utilities.getGBC(i * 2 + 2,6,1,1));
          if (lcs[i] != null && lcs[i].getB() != null) {
            f.add(new JLabel("String_Node_Str" + lcs[i].getDecodedValue()),Utilities.getGBC(i * 2 + 1,9,1,1));
          }
 else {
            f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i * 2 + 1,9,1,1));
          }
          if (lcs[i] != null && lcs[i].getB() != null) {
            f.add(new JLabel("String_Node_Str" + Math.round(10 * lcs[i].getValityPercent()) / 10.0),Utilities.getGBC(i * 2 + 1,10,1,1));
          }
 else {
            f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i * 2 + 1,10,1,1));
          }
        }
        f.pack();
      }
 else {
        if (Utilities.isLoggerActive()) {
          logger.warning("String_Node_Str");
        }
      }
      f.add(new JLabel("String_Node_Str"),Utilities.getGBC(0,11,10,1));
      f.add(new ImageComponent(captcha.getImage()),Utilities.getGBC(0,12,10,1));
      f.pack();
      return null;
    }
  }
.waitForEDT();
  if (Utilities.isLoggerActive()) {
    logger.info("String_Node_Str" + guess + "String_Node_Str"+ captcha.getValityPercent());
  }
  if (inpThread.isAlive()) {
synchronized (run) {
      try {
        run.wait();
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  if (run.ret == -2)   return -2;
  code=run.code;
  if (code == null) {
    File file=getResourceFile("String_Node_Str" + System.currentTimeMillis() + "String_Node_Str"+ captchafile.getName());
    file.getParentFile().mkdirs();
    captchafile.renameTo(file);
    if (Utilities.isLoggerActive()) {
      logger.severe("String_Node_Str");
    }
    return -1;
  }
  if (code.length() == 0) {
    code=guess;
  }
  if (code.length() != letters.length) {
    File file=getResourceFile("String_Node_Str" + System.currentTimeMillis() + "String_Node_Str"+ captchafile.getName());
    file.getParentFile().mkdirs();
    captchafile.renameTo(file);
    if (Utilities.isLoggerActive()) {
      logger.severe("String_Node_Str");
    }
    return -1;
  }
  if (code.indexOf("String_Node_Str") < 0) {
    String[] oldName=captchafile.getName().split("String_Node_Str");
    String ext=oldName[oldName.length - 1];
    String newName=captchafile.getParentFile().getAbsolutePath() + "String_Node_Str" + getMethodDirName()+ "String_Node_Str"+ code+ "String_Node_Str"+ ext;
    captchafile.renameTo(new File(newName));
  }
  int ret=0;
  for (int j=0; j < letters.length; j++) {
    final int i=j;
    if (!code.substring(i,i + 1).equals("String_Node_Str")) {
      if (guess != null && code.length() > i && guess.length() > i && code.substring(i,i + 1).equals(guess.substring(i,i + 1))) {
        ret++;
        if (lcs[i] != null) {
          lcs[i].getB().markGood();
        }
        if (lcs[i].getValityPercent() > 50) {
          letters[i].setOwner(this);
          letters[i].setSourcehash(captchaHash);
          letters[i].setDecodedValue(code.substring(i,i + 1));
          new Thread(new Runnable(){
            public void run(){
            }
          }
).start();
          letterDB.add(letters[i]);
        }
        if (!jas.getBoolean("String_Node_Str")) {
          letters[i].setOwner(this);
          letters[i].setSourcehash(captchaHash);
          letters[i].setDecodedValue(code.substring(i,i + 1));
          letterDB.add(letters[i]);
          new GuiRunnable<Object>(){
            public Object runSave(){
              f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i + 1,13,1,1));
              return null;
            }
          }
.waitForEDT();
        }
 else {
          new GuiRunnable<Object>(){
            public Object runSave(){
              f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i + 1,13,1,1));
              return null;
            }
          }
.waitForEDT();
        }
        new GuiRunnable<Object>(){
          public Object runSave(){
            f.pack();
            return null;
          }
        }
.waitForEDT();
      }
 else {
        if (Utilities.isLoggerActive()) {
          logger.info(letterDB + "String_Node_Str");
        }
        if (lcs != null && lcs[i] != null && letterDB.size() > 30 && lcs[i] != null && lcs[i].getB() != null) {
          lcs[i].getB().markBad();
        }
        letters[i].setOwner(this);
        letters[i].setSourcehash(captchaHash);
        letters[i].setDecodedValue(code.substring(i,i + 1));
        letterDB.add(letters[i]);
        new GuiRunnable<Object>(){
          public Object runSave(){
            BasicWindow.showImage(letters[i].getImage(2),"String_Node_Str" + letters[i].getDecodedValue());
            f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i + 1,13,1,1));
            f.pack();
            return null;
          }
        }
.waitForEDT();
      }
    }
 else {
      new GuiRunnable<Object>(){
        public Object runSave(){
          f.add(new JLabel("String_Node_Str"),Utilities.getGBC(i + 1,13,1,1));
          f.pack();
          return null;
        }
      }
.waitForEDT();
    }
  }
  sortLetterDB();
  new Thread(new Runnable(){
    public void run(){
      saveMTHFile();
    }
  }
).start();
  return ret;
}