Program: 186344
Project: 186344
Buggy source:
/** 
 * Creates an   {@link ImageExporter} for later use.Also performs calculations that only need to be done once for a group of files, based on a  {@link CLIArgumentsGroup}.
 * @param expectedGroup  group that should contain at least the argumentsfor the files that will later be requested. Basis for optimization preparations.
 */
public ImageExporter(Configuration config,Results results,CLIArgumentsGroup expectedGroup){
  this.results=results;
  float[] clearColor={0f,0f,0f};
  if (config.containsKey(BG_COLOR_CONFIG_KEY)) {
    try {
      Color.decode(config.getString(BG_COLOR_CONFIG_KEY)).getColorComponents(clearColor);
    }
 catch (    NumberFormatException e) {
      System.err.println("String_Node_Str" + config.getString(BG_COLOR_CONFIG_KEY));
    }
  }
  int canvasLimit=config.getInt(CANVAS_LIMIT_CONFIG_KEY,DEFAULT_CANVAS_LIMIT);
  int expectedFileCalls=0;
  int expectedMaxSizeX=1;
  int expectedMaxSizeY=1;
  for (  CLIArguments args : expectedGroup.getCLIArgumentsList()) {
    for (    File outputFile : args.getOutput()) {
      OutputMode outputMode=CLIArgumentsUtil.getOutputMode(outputFile);
      if (outputMode == OutputMode.PNG || outputMode == OutputMode.PPM) {
        expectedFileCalls=1;
        expectedMaxSizeX=max(expectedMaxSizeX,args.getResolution().x);
        expectedMaxSizeY=max(expectedMaxSizeY,args.getResolution().y);
      }
    }
  }
  GLProfile profile=GLProfile.getDefault();
  GLDrawableFactory factory=GLDrawableFactory.getFactory(profile);
  if (!factory.canCreateGLPbuffer(null)) {
    throw new Error("String_Node_Str");
  }
  GLCapabilities cap=new GLCapabilities(profile);
  cap.setDoubleBuffered(false);
  pBufferSizeX=min(canvasLimit,expectedMaxSizeX);
  pBufferSizeY=min(canvasLimit,expectedMaxSizeY);
  pBuffer=factory.createGLPbuffer(null,cap,null,pBufferSizeX,pBufferSizeY,null);
  pBuffer.getContext().makeCurrent();
  gl=pBuffer.getGL().getGL2();
  gl.glFrontFace(GL_CCW);
  gl.glClearColor(clearColor[0],clearColor[1],clearColor[2],1.0f);
  gl.glEnable(GL_DEPTH_TEST);
  gl.glCullFace(GL_BACK);
  gl.glEnable(GL_CULL_FACE);
  gl.glLightfv(GL_LIGHT0,GL_AMBIENT,new float[]{1.0f,1.0f,1.0f,1.0f},0);
  gl.glLightfv(GL_LIGHT0,GL_DIFFUSE,new float[]{1.0f,1.0f,1.0f,1.0f},0);
  gl.glLightfv(GL_LIGHT0,GL_SPECULAR,new float[]{1.0f,1.0f,1.0f,1.0f},0);
  gl.glLightfv(GL_LIGHT0,GL_POSITION,new float[]{1.0f,1.5f,-(-1.0f),0.0f},0);
  gl.glEnable(GL_LIGHT0);
  gl.glEnable(GL_LIGHTING);
  gl.glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
  if (config.getBoolean("String_Node_Str",false) || (expectedFileCalls <= 1 && expectedMaxSizeX <= canvasLimit && expectedMaxSizeY <= canvasLimit)) {
    PrimitiveBuffer buffer=new PrimitiveBuffer();
    TargetUtil.renderWorldObjects(buffer,results.getMapData());
    TargetUtil.renderObject(buffer,results.getTerrain());
    bufferRenderer=new JOGLPrimitiveBufferRenderer(gl,buffer);
  }
 else {
    bufferRenderer=null;
  }
}

Fixed version (ground truth):
/** 
 * Creates an   {@link ImageExporter} for later use.Also performs calculations that only need to be done once for a group of files, based on a  {@link CLIArgumentsGroup}.
 * @param expectedGroup  group that should contain at least the argumentsfor the files that will later be requested. Basis for optimization preparations.
 */
public ImageExporter(Configuration config,Results results,CLIArgumentsGroup expectedGroup){
  this.results=results;
  float[] clearColor={0f,0f,0f};
  if (config.containsKey(BG_COLOR_CONFIG_KEY)) {
    try {
      Color.decode(config.getString(BG_COLOR_CONFIG_KEY)).getColorComponents(clearColor);
    }
 catch (    NumberFormatException e) {
      System.err.println("String_Node_Str" + config.getString(BG_COLOR_CONFIG_KEY));
    }
  }
  int canvasLimit=config.getInt(CANVAS_LIMIT_CONFIG_KEY,DEFAULT_CANVAS_LIMIT);
  int expectedFileCalls=0;
  int expectedMaxSizeX=1;
  int expectedMaxSizeY=1;
  for (  CLIArguments args : expectedGroup.getCLIArgumentsList()) {
    for (    File outputFile : args.getOutput()) {
      OutputMode outputMode=CLIArgumentsUtil.getOutputMode(outputFile);
      if (outputMode == OutputMode.PNG || outputMode == OutputMode.PPM) {
        expectedFileCalls=1;
        expectedMaxSizeX=max(expectedMaxSizeX,args.getResolution().x);
        expectedMaxSizeY=max(expectedMaxSizeY,args.getResolution().y);
      }
    }
  }
  GLProfile profile=GLProfile.getDefault();
  GLDrawableFactory factory=GLDrawableFactory.getFactory(profile);
  if (!factory.canCreateGLPbuffer(null)) {
    throw new Error("String_Node_Str");
  }
  GLCapabilities cap=new GLCapabilities(profile);
  cap.setDoubleBuffered(false);
  pBufferSizeX=min(canvasLimit,expectedMaxSizeX);
  pBufferSizeY=min(canvasLimit,expectedMaxSizeY);
  pBuffer=factory.createGLPbuffer(null,cap,null,pBufferSizeX,pBufferSizeY,null);
  pBuffer.getContext().makeCurrent();
  gl=pBuffer.getGL().getGL2();
  gl.glFrontFace(GL_CCW);
  gl.glClearColor(clearColor[0],clearColor[1],clearColor[2],1.0f);
  gl.glEnable(GL_DEPTH_TEST);
  gl.glCullFace(GL_BACK);
  gl.glEnable(GL_CULL_FACE);
  gl.glLightfv(GL_LIGHT0,GL_AMBIENT,new float[]{1.0f,1.0f,1.0f,1.0f},0);
  gl.glLightfv(GL_LIGHT0,GL_DIFFUSE,new float[]{1.0f,1.0f,1.0f,1.0f},0);
  gl.glLightfv(GL_LIGHT0,GL_SPECULAR,new float[]{1.0f,1.0f,1.0f,1.0f},0);
  gl.glLightfv(GL_LIGHT0,GL_POSITION,new float[]{1.0f,1.5f,-(-1.0f),0.0f},0);
  gl.glEnable(GL_LIGHT0);
  gl.glEnable(GL_LIGHTING);
  gl.glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
  boolean onlyOneRenderPass=(expectedFileCalls <= 1 && expectedMaxSizeX <= canvasLimit && expectedMaxSizeY <= canvasLimit);
  if (config.getBoolean("String_Node_Str",false) || onlyOneRenderPass) {
    bufferRenderer=null;
  }
 else {
    PrimitiveBuffer buffer=new PrimitiveBuffer();
    TargetUtil.renderWorldObjects(buffer,results.getMapData());
    TargetUtil.renderObject(buffer,results.getTerrain());
    bufferRenderer=new JOGLPrimitiveBufferRenderer(gl,buffer);
  }
}