Program: 519
Project: 519
Buggy source:
/** 
 * Schedules the saving of screenshot data to file. Screenshot data from the GPU is obtained as soon as this method executes. However, the data is only scheduled to be written to file, by submitting a task to the ThreadManager. The task is then executed as soon as possible but not necessarily immediately. The file is then saved in the designated screenshot folder with a filename in the form: Terasology-[yyMMddHHmmss]-[width]x[height].[format] If no screenshot data is available an error is logged and the method returns doing nothing.
 */
public void saveScreenshot(){
  FBO sceneFinalFbo=displayResolutionDependentFBOs.get(FINAL_BUFFER);
  final ByteBuffer buffer=sceneFinalFbo.getColorBufferRawData();
  if (buffer == null) {
    logger.error("String_Node_Str");
    return;
  }
  int width=sceneFinalFbo.width();
  int height=sceneFinalFbo.height();
  Runnable task=() -> {
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str");
    final String format=renderingConfig.getScreenshotFormat();
    final String fileName="String_Node_Str" + sdf.format(new Date()) + "String_Node_Str"+ width+ "String_Node_Str"+ height+ "String_Node_Str"+ format;
    Path path=PathManager.getInstance().getScreenshotPath().resolve(fileName);
    BufferedImage image=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
    for (int x=0; x < width; x++) {
      for (int y=0; y < height; y++) {
        int i=(x + width * y) * 4;
        int r=buffer.get(i) & 0xFF;
        int g=buffer.get(i + 1) & 0xFF;
        int b=buffer.get(i + 2) & 0xFF;
        image.setRGB(x,height - (y + 1),(0xFF << 24) | (r << 16) | (g << 8)| b);
      }
    }
    try (OutputStream out=new BufferedOutputStream(Files.newOutputStream(path))){
      ImageIO.write(image,format,out);
      logger.info("String_Node_Str" + fileName + "String_Node_Str");
    }
 catch (    IOException e) {
      logger.warn("String_Node_Str",e);
    }
  }
;
  threadManager.submitTask("String_Node_Str",task);
  isTakingScreenshot=false;
}

Fixed version (ground truth):
/** 
 * Schedules the saving of screenshot data to file. Screenshot data from the GPU is obtained as soon as this method executes. However, the data is only scheduled to be written to file, by submitting a task to the ThreadManager. The task is then executed as soon as possible but not necessarily immediately. The file is then saved in the designated screenshot folder with a filename in the form: Terasology-[yyMMddHHmmss]-[width]x[height].[format] If no screenshot data is available an error is logged and the method returns doing nothing.
 */
public void saveScreenshot(){
  if (displayResolutionDependentFBOs == null)   displayResolutionDependentFBOs=CoreRegistry.get(DisplayResolutionDependentFBOs.class);
  FBO sceneFinalFbo=displayResolutionDependentFBOs.get(FINAL_BUFFER);
  final ByteBuffer buffer=sceneFinalFbo.getColorBufferRawData();
  if (buffer == null) {
    logger.error("String_Node_Str");
    return;
  }
  int width=sceneFinalFbo.width();
  int height=sceneFinalFbo.height();
  Runnable task=() -> {
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str");
    final String format=renderingConfig.getScreenshotFormat();
    final String fileName="String_Node_Str" + sdf.format(new Date()) + "String_Node_Str"+ width+ "String_Node_Str"+ height+ "String_Node_Str"+ format;
    Path path=PathManager.getInstance().getScreenshotPath().resolve(fileName);
    BufferedImage image=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
    for (int x=0; x < width; x++) {
      for (int y=0; y < height; y++) {
        int i=(x + width * y) * 4;
        int r=buffer.get(i) & 0xFF;
        int g=buffer.get(i + 1) & 0xFF;
        int b=buffer.get(i + 2) & 0xFF;
        image.setRGB(x,height - (y + 1),(0xFF << 24) | (r << 16) | (g << 8)| b);
      }
    }
    try (OutputStream out=new BufferedOutputStream(Files.newOutputStream(path))){
      ImageIO.write(image,format,out);
      logger.info("String_Node_Str" + fileName + "String_Node_Str");
    }
 catch (    IOException e) {
      logger.warn("String_Node_Str",e);
    }
  }
;
  threadManager.submitTask("String_Node_Str",task);
  isTakingScreenshot=false;
}