Program: 160486
Project: 160486
Buggy source:
@Override public void run(){
  targetModel.generateMinimalExpressIds();
  Serializer ifcSerializer=ifcSerializerPlugin.createSerializer(new PluginConfiguration());
  RenderEngine renderEngine=null;
  try {
    renderEngine=renderEnginePlugin.createRenderEngine(new PluginConfiguration(),"String_Node_Str");
  }
 catch (  RenderEngineException e2) {
    e2.printStackTrace();
  }
  try {
    renderEngine.init();
    ifcSerializer.init(targetModel,null,pluginManager,null,pluginManager.getMetaDataManager().getPackageMetaData("String_Node_Str"),true);
    RenderEngineModel renderEngineModel=renderEngine.openModel(ifcSerializer.getInputStream());
    try {
      renderEngineModel.setSettings(settings);
      renderEngineModel.generateGeneralGeometry();
      List<IdEObject> allWithSubTypes=targetModel.getAll(eClass);
      for (      IdEObject ifcProduct : allWithSubTypes) {
        IdEObject representation=(IdEObject)ifcProduct.eGet(representationFeature);
        if (representation != null && ((List<?>)representation.eGet(representationsFeature)).size() > 0) {
          try {
            RenderEngineInstance renderEngineInstance=renderEngineModel.getInstanceFromExpressId(ifcProduct.getExpressId());
            RenderEngineGeometry geometry=renderEngineInstance.generateGeometry();
            if (geometry != null && geometry.getNrIndices() > 0) {
              GeometryInfo geometryInfo=null;
              if (store) {
                geometryInfo=databaseSession.create(GeometryPackage.eINSTANCE.getGeometryInfo(),pid,rid);
              }
 else {
                geometryInfo=GeometryFactory.eINSTANCE.createGeometryInfo();
              }
              geometryInfo.setMinBounds(createVector3f(Float.POSITIVE_INFINITY,databaseSession,store,pid,rid));
              geometryInfo.setMaxBounds(createVector3f(Float.NEGATIVE_INFINITY,databaseSession,store,pid,rid));
              GeometryData geometryData=null;
              if (store) {
                geometryData=databaseSession.create(GeometryPackage.eINSTANCE.getGeometryData(),pid,rid);
              }
 else {
                geometryData=GeometryFactory.eINSTANCE.createGeometryData();
              }
              geometryData.setIndices(intArrayToByteArray(geometry.getIndices()));
              geometryData.setVertices(floatArrayToByteArray(geometry.getVertices()));
              geometryData.setMaterialIndices(intArrayToByteArray(geometry.getMaterialIndices()));
              geometryData.setNormals(floatArrayToByteArray(geometry.getNormals()));
              if (geometry.getMaterialIndices() != null && geometry.getMaterialIndices().length > 0) {
                boolean hasMaterial=false;
                float[] vertex_colors=new float[geometry.getVertices().length / 3 * 4];
                for (int i=0; i < geometry.getMaterialIndices().length; ++i) {
                  int c=geometry.getMaterialIndices()[i];
                  for (int j=0; j < 3; ++j) {
                    int k=geometry.getIndices()[i * 3 + j];
                    if (c > -1) {
                      hasMaterial=true;
                      for (int l=0; l < 4; ++l) {
                        vertex_colors[4 * k + l]=geometry.getMaterials()[4 * c + l];
                      }
                    }
                  }
                }
                if (hasMaterial) {
                  geometryData.setMaterials(floatArrayToByteArray(vertex_colors));
                }
              }
              float[] tranformationMatrix=new float[16];
              if (renderEngineInstance.getTransformationMatrix() != null) {
                tranformationMatrix=renderEngineInstance.getTransformationMatrix();
                tranformationMatrix=Matrix.changeOrientation(tranformationMatrix);
              }
 else {
                Matrix.setIdentityM(tranformationMatrix,0);
              }
              for (int i=0; i < geometry.getIndices().length; i++) {
                processExtends(geometryInfo,tranformationMatrix,geometry.getVertices(),geometry.getIndices()[i] * 3);
              }
              geometryInfo.setData(geometryData);
              setTransformationMatrix(geometryInfo,tranformationMatrix);
              if (bimServer.getServerSettingsCache().getServerSettings().isReuseGeometry()) {
                int hash=hash(geometryData);
                if (hashes.containsKey(hash)) {
                  databaseSession.removeFromCommit(geometryData);
                  geometryInfo.setData(hashes.get(hash));
                }
 else {
                  hashes.put(hash,geometryData);
                }
              }
              bigMap.get(ifcProduct).eSet(geometryFeature,geometryInfo);
              ifcProduct.eSet(geometryFeature,geometryInfo);
              if (store) {
                databaseSession.store(bigMap.get(ifcProduct),pid,rid);
              }
            }
          }
 catch (          BimserverDatabaseException|RenderEngineException e) {
            if (!(ifcProduct instanceof IfcAnnotation)) {
              LOGGER.info("String_Node_Str" + ifcProduct.eClass().getName() + "String_Node_Str"+ ifcProduct.getExpressId()+ "String_Node_Str"+ ifcProduct.getOid());
            }
          }
        }
      }
    }
  finally {
      renderEngineModel.close();
    }
  }
 catch (  SerializerException|RenderEngineException|IOException e) {
    LOGGER.error("String_Node_Str",e);
  }
 finally {
    try {
      renderEngine.close();
    }
 catch (    RenderEngineException e) {
      LOGGER.error("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  targetModel.generateMinimalExpressIds();
  Serializer ifcSerializer=ifcSerializerPlugin.createSerializer(new PluginConfiguration());
  RenderEngine renderEngine=null;
  try {
    renderEngine=renderEnginePlugin.createRenderEngine(new PluginConfiguration(),"String_Node_Str");
  }
 catch (  RenderEngineException e2) {
    e2.printStackTrace();
  }
  try {
    renderEngine.init();
    ifcSerializer.init(targetModel,null,pluginManager,null,pluginManager.getMetaDataManager().getPackageMetaData("String_Node_Str"),true);
    boolean debug=false;
    InputStream in=null;
    if (debug) {
      File file=new File(eClass.getName() + "String_Node_Str");
      FileOutputStream fos=new FileOutputStream(file);
      IOUtils.copy(ifcSerializer.getInputStream(),fos);
      fos.close();
      in=new FileInputStream(file);
    }
 else {
      in=ifcSerializer.getInputStream();
    }
    RenderEngineModel renderEngineModel=renderEngine.openModel(in);
    try {
      renderEngineModel.setSettings(settings);
      renderEngineModel.generateGeneralGeometry();
      List<IdEObject> allWithSubTypes=targetModel.getAll(eClass);
      for (      IdEObject ifcProduct : allWithSubTypes) {
        IdEObject representation=(IdEObject)ifcProduct.eGet(representationFeature);
        if (representation != null && ((List<?>)representation.eGet(representationsFeature)).size() > 0) {
          try {
            RenderEngineInstance renderEngineInstance=renderEngineModel.getInstanceFromExpressId(ifcProduct.getExpressId());
            RenderEngineGeometry geometry=renderEngineInstance.generateGeometry();
            if (geometry != null && geometry.getNrIndices() > 0) {
              GeometryInfo geometryInfo=null;
              if (store) {
                geometryInfo=databaseSession.create(GeometryPackage.eINSTANCE.getGeometryInfo(),pid,rid);
              }
 else {
                geometryInfo=GeometryFactory.eINSTANCE.createGeometryInfo();
              }
              geometryInfo.setMinBounds(createVector3f(Float.POSITIVE_INFINITY,databaseSession,store,pid,rid));
              geometryInfo.setMaxBounds(createVector3f(Float.NEGATIVE_INFINITY,databaseSession,store,pid,rid));
              GeometryData geometryData=null;
              if (store) {
                geometryData=databaseSession.create(GeometryPackage.eINSTANCE.getGeometryData(),pid,rid);
              }
 else {
                geometryData=GeometryFactory.eINSTANCE.createGeometryData();
              }
              geometryData.setIndices(intArrayToByteArray(geometry.getIndices()));
              geometryData.setVertices(floatArrayToByteArray(geometry.getVertices()));
              geometryData.setMaterialIndices(intArrayToByteArray(geometry.getMaterialIndices()));
              geometryData.setNormals(floatArrayToByteArray(geometry.getNormals()));
              if (geometry.getMaterialIndices() != null && geometry.getMaterialIndices().length > 0) {
                boolean hasMaterial=false;
                float[] vertex_colors=new float[geometry.getVertices().length / 3 * 4];
                for (int i=0; i < geometry.getMaterialIndices().length; ++i) {
                  int c=geometry.getMaterialIndices()[i];
                  for (int j=0; j < 3; ++j) {
                    int k=geometry.getIndices()[i * 3 + j];
                    if (c > -1) {
                      hasMaterial=true;
                      for (int l=0; l < 4; ++l) {
                        vertex_colors[4 * k + l]=geometry.getMaterials()[4 * c + l];
                      }
                    }
                  }
                }
                if (hasMaterial) {
                  geometryData.setMaterials(floatArrayToByteArray(vertex_colors));
                }
              }
              float[] tranformationMatrix=new float[16];
              if (renderEngineInstance.getTransformationMatrix() != null) {
                tranformationMatrix=renderEngineInstance.getTransformationMatrix();
                tranformationMatrix=Matrix.changeOrientation(tranformationMatrix);
              }
 else {
                Matrix.setIdentityM(tranformationMatrix,0);
              }
              for (int i=0; i < geometry.getIndices().length; i++) {
                processExtends(geometryInfo,tranformationMatrix,geometry.getVertices(),geometry.getIndices()[i] * 3);
              }
              geometryInfo.setData(geometryData);
              setTransformationMatrix(geometryInfo,tranformationMatrix);
              if (bimServer.getServerSettingsCache().getServerSettings().isReuseGeometry()) {
                int hash=hash(geometryData);
                if (hashes.containsKey(hash)) {
                  databaseSession.removeFromCommit(geometryData);
                  geometryInfo.setData(hashes.get(hash));
                }
 else {
                  hashes.put(hash,geometryData);
                }
              }
              bigMap.get(ifcProduct).eSet(geometryFeature,geometryInfo);
              ifcProduct.eSet(geometryFeature,geometryInfo);
              if (store) {
                databaseSession.store(bigMap.get(ifcProduct),pid,rid);
              }
            }
          }
 catch (          EntityNotFoundException e) {
            if (!(ifcProduct instanceof IfcAnnotation)) {
              LOGGER.info("String_Node_Str" + ifcProduct.eClass().getName() + "String_Node_Str"+ ifcProduct.getExpressId()+ "String_Node_Str"+ ifcProduct.getOid());
            }
          }
catch (          BimserverDatabaseException|RenderEngineException e) {
            LOGGER.error("String_Node_Str",e);
          }
        }
      }
    }
  finally {
      renderEngineModel.close();
    }
  }
 catch (  SerializerException|RenderEngineException|IOException e) {
    LOGGER.error("String_Node_Str",e);
  }
 finally {
    try {
      renderEngine.close();
    }
 catch (    RenderEngineException e) {
      LOGGER.error("String_Node_Str",e);
    }
  }
}