Program: 160495
Project: 160495
Buggy source:
@Override public IfcModelInterface execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
  DatabaseSession session=getBimServer().getDatabase().createSession();
  try {
    SerializerPluginConfiguration serializerPluginConfiguration=getDatabaseSession().get(StorePackage.eINSTANCE.getSerializerPluginConfiguration(),serializerOid,Query.getDefault());
    BimDatabaseAction<IfcModelInterface> action=new DownloadDatabaseAction(getBimServer(),session,AccessMethod.INTERNAL,roid,-1,serializerPluginConfiguration.getOid(),getAuthorization(),null);
    IfcModelInterface ifcModel=session.executeAndCommitAction(action);
    QueryEnginePluginConfiguration queryEngineObject=session.get(StorePackage.eINSTANCE.getQueryEnginePluginConfiguration(),qeid,Query.getDefault());
    if (queryEngineObject != null) {
      QueryEnginePlugin queryEnginePlugin=getBimServer().getPluginManager().getQueryEngine(queryEngineObject.getPluginDescriptor().getPluginClassName(),true);
      if (queryEnginePlugin != null) {
        org.bimserver.plugins.queryengine.QueryEngine queryEngine=queryEnginePlugin.getQueryEngine(new PluginConfiguration(queryEngineObject.getSettings()));
        IfcModelInterface result=new IfcModel(null,null);
        IfcModelInterface finalResult=queryEngine.query(ifcModel,code,new Reporter(){
          @Override public void error(          Exception error){
          }
          @Override public void warning(          String warning){
          }
          @Override public void info(          String info){
          }
        }
,new ModelHelper(objectIDM,result));
        return finalResult;
      }
 else {
        throw new UserException("String_Node_Str" + queryEngineObject.getPluginDescriptor().getPluginClassName());
      }
    }
 else {
      throw new UserException("String_Node_Str" + qeid);
    }
  }
 catch (  BimserverDatabaseException e) {
    throw new UserException(e);
  }
catch (  QueryEngineException e) {
    throw new UserException(e);
  }
 finally {
    session.close();
  }
}

Fixed version (ground truth):
@Override public IfcModelInterface execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
  DatabaseSession session=getBimServer().getDatabase().createSession();
  try {
    SerializerPluginConfiguration serializerPluginConfiguration=getDatabaseSession().get(StorePackage.eINSTANCE.getSerializerPluginConfiguration(),serializerOid,Query.getDefault());
    BimDatabaseAction<IfcModelInterface> action=new DownloadDatabaseAction(getBimServer(),session,AccessMethod.INTERNAL,roid,-1,serializerPluginConfiguration.getOid(),getAuthorization(),null);
    IfcModelInterface ifcModel=session.executeAndCommitAction(action);
    QueryEnginePluginConfiguration queryEngineObject=session.get(StorePackage.eINSTANCE.getQueryEnginePluginConfiguration(),qeid,Query.getDefault());
    Revision revision=session.get(roid,Query.getDefault());
    PackageMetaData packageMetaData=getBimServer().getMetaDataManager().getEPackage(revision.getProject().getSchema());
    if (queryEngineObject != null) {
      QueryEnginePlugin queryEnginePlugin=getBimServer().getPluginManager().getQueryEngine(queryEngineObject.getPluginDescriptor().getPluginClassName(),true);
      if (queryEnginePlugin != null) {
        QueryEngine queryEngine=queryEnginePlugin.getQueryEngine(new PluginConfiguration(queryEngineObject.getSettings()));
        IfcModelInterface result=new IfcModel(packageMetaData,null);
        IfcModelInterface finalResult=queryEngine.query(ifcModel,code,new Reporter(){
          @Override public void error(          Exception error){
          }
          @Override public void warning(          String warning){
          }
          @Override public void info(          String info){
          }
        }
,new ModelHelper(objectIDM,result));
        return finalResult;
      }
 else {
        throw new UserException("String_Node_Str" + queryEngineObject.getPluginDescriptor().getPluginClassName());
      }
    }
 else {
      throw new UserException("String_Node_Str" + qeid);
    }
  }
 catch (  BimserverDatabaseException e) {
    throw new UserException(e);
  }
catch (  QueryEngineException e) {
    throw new UserException(e);
  }
 finally {
    session.close();
  }
}