Program: 133342
Project: 133342
Buggy source:
/** 
 * Grabs the MESH DATA MeshComponent from the componentMap and writes the contents to the specified OutputStream. In the process of iterating through each element/quad, this method also constructs 2+ ArrayLists of Strings (thermal, fluid and if any passive scalar BCs) representing lines of boundary conditions in a reafile. These ArrayLists are passed into the writeBoundaryConditions(...) method.
 * @param stream The OutputStream to write to
 * @throws IOException Thrown when writing to OutputStream fails
 */
private void writeMesh(OutputStream stream) throws IOException {
  MeshComponent mesh=(MeshComponent)componentMap.get("String_Node_Str");
  NekPolygonController currQuad;
  IController currEdge;
  int currEdgeId;
  ArrayList<VertexController> currVertices=new ArrayList<VertexController>();
  String currValue;
  StringBuffer buffer=new StringBuffer();
  ArrayList<String> bufferArray=new ArrayList<String>();
  ArrayList<Float> xCoords=new ArrayList<Float>();
  ArrayList<Float> yCoords=new ArrayList<Float>();
  BoundaryCondition currBC;
  ArrayList<Float> currBCValues=new ArrayList<Float>();
  ArrayList<String> thermalBCs=new ArrayList<String>();
  ArrayList<String> fluidBCs=new ArrayList<String>();
  ArrayList<ArrayList<String>> passiveScalarBCs=null;
  for (int i=0; i < mesh.getPolygons().size(); i++) {
    currQuad=(NekPolygonController)mesh.getPolygons().get(i);
    currValue=String.format("String_Node_Str" + "String_Node_Str",(i + 1),currQuad.getPolygonProperties().getMaterialId(),currQuad.getPolygonProperties().getGroupNum());
    buffer.append(currValue);
    for (    IController entity : currQuad.getEntitiesFromCategory(MeshCategory.EDGES)) {
      for (      VertexController v : entity.getEntitiesFromCategory(MeshCategory.VERTICES,VertexController.class)) {
        if (!currVertices.contains(v)) {
          currVertices.add(v);
        }
      }
    }
    for (int k=0; k < 4; k++) {
      xCoords.add((float)currVertices.get(k).getTranslation()[0]);
      yCoords.add((float)currVertices.get(k).getTranslation()[1]);
    }
    for (int j=0; j < 4; j++) {
      currEdge=currQuad.getEntitiesFromCategory(MeshCategory.EDGES).get(j);
      currEdgeId=Integer.valueOf(currEdge.getProperty(MeshProperty.ID));
      currBC=currQuad.getFluidBoundaryCondition(currEdgeId);
      if (currBC.getType() != BoundaryConditionType.None) {
        currBCValues=currBC.getValues();
        currValue=String.format("String_Node_Str",currBC.getType().id,(i + 1),(j + 1),currBCValues.get(0),currBCValues.get(1),currBCValues.get(2),currBCValues.get(3),currBCValues.get(4));
        fluidBCs.add(currValue);
      }
      currBC=currQuad.getThermalBoundaryCondition(currEdgeId);
      if (currBC.getType() != BoundaryConditionType.None) {
        currBCValues=currBC.getValues();
        currValue=String.format("String_Node_Str",currBC.getType().id,(i + 1),(j + 1),currBCValues.get(0),currBCValues.get(1),currBCValues.get(2),currBCValues.get(3),currBCValues.get(4));
        thermalBCs.add(currValue);
      }
      if (properties.getNumPassiveScalars() > 0) {
        passiveScalarBCs=new ArrayList<ArrayList<String>>(properties.getNumPassiveScalars());
        for (int k=1; k <= properties.getNumPassiveScalars(); k++) {
          currBC=currQuad.getOtherBoundaryCondition(currEdgeId,k);
          if (currBC.getType() != BoundaryConditionType.None) {
            currBCValues=currBC.getValues();
            currValue=String.format("String_Node_Str",currBC.getType().id,(i + 1),(j + 1),currBCValues.get(0),currBCValues.get(1),currBCValues.get(2),currBCValues.get(3),currBCValues.get(4));
            passiveScalarBCs.get(k).add(currValue);
          }
        }
      }
    }
    currValue=String.format("String_Node_Str" + "String_Node_Str",xCoords.get(0),xCoords.get(1),xCoords.get(2),xCoords.get(3),yCoords.get(0),yCoords.get(1),yCoords.get(2),yCoords.get(3));
    buffer.append(currValue);
    xCoords.clear();
    yCoords.clear();
  }
  updateProperties(properties.getNumDimensions(),thermalBCs.isEmpty() ? properties.getNumThermalElements() : thermalBCs.size() / 4,fluidBCs.isEmpty() ? properties.getNumFluidElements() : fluidBCs.size() / 4,passiveScalarBCs == null ? 0 : passiveScalarBCs.size() / 4);
  String meshHeader=String.format("String_Node_Str" + "String_Node_Str",properties.getNumThermalElements(),properties.getNumDimensions(),properties.getNumFluidElements());
  buffer.insert(0,meshHeader);
  byte[] byteArray=buffer.toString().getBytes();
  stream.write(byteArray);
  writeCurvedSideData(stream);
  writeBoundaryConditions(stream,fluidBCs,thermalBCs,passiveScalarBCs);
  return;
}

Fixed version (ground truth):
/** 
 * Grabs the MESH DATA MeshComponent from the componentMap and writes the contents to the specified OutputStream. In the process of iterating through each element/quad, this method also constructs 2+ ArrayLists of Strings (thermal, fluid and if any passive scalar BCs) representing lines of boundary conditions in a reafile. These ArrayLists are passed into the writeBoundaryConditions(...) method.
 * @param stream The OutputStream to write to
 * @throws IOException Thrown when writing to OutputStream fails
 */
private void writeMesh(OutputStream stream) throws IOException {
  MeshComponent mesh=(MeshComponent)componentMap.get("String_Node_Str");
  NekPolygonController currQuad;
  IController currEdge;
  int currEdgeId;
  String currValue;
  StringBuffer buffer=new StringBuffer();
  ArrayList<String> bufferArray=new ArrayList<String>();
  ArrayList<Float> xCoords=new ArrayList<Float>();
  ArrayList<Float> yCoords=new ArrayList<Float>();
  BoundaryCondition currBC;
  ArrayList<Float> currBCValues=new ArrayList<Float>();
  ArrayList<String> thermalBCs=new ArrayList<String>();
  ArrayList<String> fluidBCs=new ArrayList<String>();
  ArrayList<ArrayList<String>> passiveScalarBCs=null;
  for (int i=0; i < mesh.getPolygons().size(); i++) {
    currQuad=(NekPolygonController)mesh.getPolygons().get(i);
    currValue=String.format("String_Node_Str" + "String_Node_Str",(i + 1),currQuad.getPolygonProperties().getMaterialId(),currQuad.getPolygonProperties().getGroupNum());
    buffer.append(currValue);
    for (    EdgeController entity : currQuad.getEntitiesFromCategory(MeshCategory.EDGES,EdgeController.class)) {
      xCoords.add((float)entity.getStartLocation()[0]);
      yCoords.add((float)entity.getStartLocation()[1]);
    }
    for (int j=0; j < 4; j++) {
      currEdge=currQuad.getEntitiesFromCategory(MeshCategory.EDGES).get(j);
      currEdgeId=Integer.valueOf(currEdge.getProperty(MeshProperty.ID));
      currBC=currQuad.getFluidBoundaryCondition(currEdgeId);
      if (currBC.getType() != BoundaryConditionType.None) {
        currBCValues=currBC.getValues();
        currValue=String.format("String_Node_Str",currBC.getType().id,(i + 1),(j + 1),currBCValues.get(0),currBCValues.get(1),currBCValues.get(2),currBCValues.get(3),currBCValues.get(4));
        fluidBCs.add(currValue);
      }
      currBC=currQuad.getThermalBoundaryCondition(currEdgeId);
      if (currBC.getType() != BoundaryConditionType.None) {
        currBCValues=currBC.getValues();
        currValue=String.format("String_Node_Str",currBC.getType().id,(i + 1),(j + 1),currBCValues.get(0),currBCValues.get(1),currBCValues.get(2),currBCValues.get(3),currBCValues.get(4));
        thermalBCs.add(currValue);
      }
      if (properties.getNumPassiveScalars() > 0) {
        passiveScalarBCs=new ArrayList<ArrayList<String>>(properties.getNumPassiveScalars());
        for (int k=1; k <= properties.getNumPassiveScalars(); k++) {
          currBC=currQuad.getOtherBoundaryCondition(currEdgeId,k);
          if (currBC.getType() != BoundaryConditionType.None) {
            currBCValues=currBC.getValues();
            currValue=String.format("String_Node_Str",currBC.getType().id,(i + 1),(j + 1),currBCValues.get(0),currBCValues.get(1),currBCValues.get(2),currBCValues.get(3),currBCValues.get(4));
            passiveScalarBCs.get(k).add(currValue);
          }
        }
      }
    }
    currValue=String.format("String_Node_Str" + "String_Node_Str",xCoords.get(0),xCoords.get(1),xCoords.get(2),xCoords.get(3),yCoords.get(0),yCoords.get(1),yCoords.get(2),yCoords.get(3));
    buffer.append(currValue);
    xCoords.clear();
    yCoords.clear();
  }
  updateProperties(properties.getNumDimensions(),thermalBCs.isEmpty() ? properties.getNumThermalElements() : thermalBCs.size() / 4,fluidBCs.isEmpty() ? properties.getNumFluidElements() : fluidBCs.size() / 4,passiveScalarBCs == null ? 0 : passiveScalarBCs.size() / 4);
  String meshHeader=String.format("String_Node_Str" + "String_Node_Str",properties.getNumThermalElements(),properties.getNumDimensions(),properties.getNumFluidElements());
  buffer.insert(0,meshHeader);
  byte[] byteArray=buffer.toString().getBytes();
  stream.write(byteArray);
  writeCurvedSideData(stream);
  writeBoundaryConditions(stream,fluidBCs,thermalBCs,passiveScalarBCs);
  return;
}