Program: 160492
Project: 160492
Buggy source:
private void initDatabaseDependantItems() throws BimserverDatabaseException {
  serverSettingsCache.init();
  notificationsManager.init();
  getSerializerFactory().init(pluginManager,bimDatabase,this);
  getDeserializerFactory().init(pluginManager,bimDatabase);
  try {
    DatabaseSession session=bimDatabase.createSession();
    try {
      updatePlugins(session);
      session.commit();
    }
 catch (    ServiceException e) {
      LOGGER.error("String_Node_Str",e);
    }
 finally {
      session.close();
    }
    session=bimDatabase.createSession();
    createDatabaseObjects(session);
    ServerSettings serverSettings=serverSettingsCache.getServerSettings();
    for (    WebModulePlugin webModulePlugin : pluginManager.getAllWebPlugins(true)) {
      WebModulePluginConfiguration webPluginConfiguration=find(serverSettings.getWebModules(),webModulePlugin.getClass().getName());
      if (webPluginConfiguration == null) {
        webPluginConfiguration=session.create(WebModulePluginConfiguration.class);
        serverSettings.getWebModules().add(webPluginConfiguration);
        genericPluginConversion(session,webModulePlugin,webPluginConfiguration,getPluginDescriptor(session,webModulePlugin.getClass().getName()));
      }
      if (webPluginConfiguration == serverSettings.getWebModule()) {
        setDefaultWebModule(webModulePlugin);
      }
 else {
        if (webModulePlugin.getClass().getName().equals("String_Node_Str")) {
          serverSettings.setWebModule(webPluginConfiguration);
          setDefaultWebModule(webModulePlugin);
        }
        if (webModulePlugin.getClass().getName().equals("String_Node_Str")) {
          serverSettings.setWebModule(webPluginConfiguration);
          setDefaultWebModule(webModulePlugin);
        }
      }
    }
    session.store(serverSettings);
    Condition condition=new AttributeCondition(StorePackage.eINSTANCE.getUser_Username(),new StringLiteral("String_Node_Str"));
    User systemUser=session.querySingle(condition,User.class,Query.getDefault());
    ServerStarted serverStarted=session.create(ServerStarted.class);
    serverStarted.setDate(new Date());
    serverStarted.setAccessMethod(AccessMethod.INTERNAL);
    serverStarted.setExecutor(systemUser);
    try {
      session.store(serverStarted);
      session.commit();
    }
 catch (    BimserverLockConflictException e) {
      throw new BimserverDatabaseException(e);
    }
catch (    ServiceException e) {
      throw new BimserverDatabaseException(e);
    }
 finally {
      session.close();
    }
    webModules=new HashMap<String,WebModulePlugin>();
    DatabaseSession ses=bimDatabase.createSession();
    try {
      List<WebModulePluginConfiguration> webModuleConfigurations=serverSettingsCache.getServerSettings().getWebModules();
      for (      WebModulePluginConfiguration webModulePluginConfiguration : webModuleConfigurations) {
        String contextPath="String_Node_Str";
        for (        Parameter parameter : webModulePluginConfiguration.getSettings().getParameters()) {
          if (parameter.getName().equals("String_Node_Str")) {
            contextPath=((StringType)parameter.getValue()).getValue();
          }
        }
        webModules.put(contextPath,(WebModulePlugin)pluginManager.getPlugin(webModulePluginConfiguration.getPluginDescriptor().getPluginClassName(),true));
      }
      if (serverSettingsCache.getServerSettings().getWebModule() != null) {
        defaultWebModule=(WebModulePlugin)pluginManager.getPlugin(serverSettingsCache.getServerSettings().getWebModule().getPluginDescriptor().getPluginClassName(),true);
      }
    }
  finally {
      ses.close();
    }
    Integer protocolBuffersPort=getServerSettingsCache().getServerSettings().getProtocolBuffersPort();
    if (protocolBuffersPort >= 1 && protocolBuffersPort <= 65535) {
      try {
        protocolBuffersServer=new ProtocolBuffersServer(protocolBuffersMetaData,serviceFactory,servicesMap,protocolBuffersPort);
        protocolBuffersServer.start();
      }
 catch (      Exception e) {
        LOGGER.error("String_Node_Str",e);
      }
    }
    bimServerClientFactory=new DirectBimServerClientFactory<ServiceInterface>(serverSettingsCache.getServerSettings().getSiteAddress(),serviceFactory,servicesMap,pluginManager,metaDataManager);
    pluginManager.setBimServerClientFactory(bimServerClientFactory);
  }
 catch (  BimserverLockConflictException e) {
    throw new BimserverDatabaseException(e);
  }
catch (  PluginException e) {
    throw new BimserverDatabaseException(e);
  }
}

Fixed version (ground truth):
private void initDatabaseDependantItems() throws BimserverDatabaseException {
  serverSettingsCache.init();
  notificationsManager.init();
  getSerializerFactory().init(pluginManager,bimDatabase,this);
  getDeserializerFactory().init(pluginManager,bimDatabase);
  try {
    DatabaseSession session=bimDatabase.createSession();
    try {
      updatePlugins(session);
      session.commit();
    }
 catch (    ServiceException e) {
      LOGGER.error("String_Node_Str",e);
    }
 finally {
      session.close();
    }
    session=bimDatabase.createSession();
    createDatabaseObjects(session);
    ServerSettings serverSettings=serverSettingsCache.getServerSettings();
    for (    WebModulePlugin webModulePlugin : pluginManager.getAllWebPlugins(true)) {
      WebModulePluginConfiguration webPluginConfiguration=find(serverSettings.getWebModules(),webModulePlugin.getClass().getName());
      if (webPluginConfiguration == null) {
        webPluginConfiguration=session.create(WebModulePluginConfiguration.class);
        serverSettings.getWebModules().add(webPluginConfiguration);
        genericPluginConversion(session,webModulePlugin,webPluginConfiguration,getPluginDescriptor(session,webModulePlugin.getClass().getName()));
      }
      if (serverSettings.getWebModule() == null) {
        if (webModulePlugin.getClass().getName().equals("String_Node_Str")) {
          serverSettings.setWebModule(webPluginConfiguration);
          setDefaultWebModule(webModulePlugin);
        }
        if (webModulePlugin.getClass().getName().equals("String_Node_Str")) {
          serverSettings.setWebModule(webPluginConfiguration);
          setDefaultWebModule(webModulePlugin);
        }
      }
 else {
        if (webPluginConfiguration == serverSettings.getWebModule()) {
          setDefaultWebModule(webModulePlugin);
        }
      }
    }
    session.store(serverSettings);
    Condition condition=new AttributeCondition(StorePackage.eINSTANCE.getUser_Username(),new StringLiteral("String_Node_Str"));
    User systemUser=session.querySingle(condition,User.class,Query.getDefault());
    ServerStarted serverStarted=session.create(ServerStarted.class);
    serverStarted.setDate(new Date());
    serverStarted.setAccessMethod(AccessMethod.INTERNAL);
    serverStarted.setExecutor(systemUser);
    try {
      session.store(serverStarted);
      session.commit();
    }
 catch (    BimserverLockConflictException e) {
      throw new BimserverDatabaseException(e);
    }
catch (    ServiceException e) {
      throw new BimserverDatabaseException(e);
    }
 finally {
      session.close();
    }
    webModules=new HashMap<String,WebModulePlugin>();
    DatabaseSession ses=bimDatabase.createSession();
    try {
      List<WebModulePluginConfiguration> webModuleConfigurations=serverSettingsCache.getServerSettings().getWebModules();
      for (      WebModulePluginConfiguration webModulePluginConfiguration : webModuleConfigurations) {
        String contextPath="String_Node_Str";
        for (        Parameter parameter : webModulePluginConfiguration.getSettings().getParameters()) {
          if (parameter.getName().equals("String_Node_Str")) {
            contextPath=((StringType)parameter.getValue()).getValue();
          }
        }
        webModules.put(contextPath,(WebModulePlugin)pluginManager.getPlugin(webModulePluginConfiguration.getPluginDescriptor().getPluginClassName(),true));
      }
      if (serverSettingsCache.getServerSettings().getWebModule() != null) {
        defaultWebModule=(WebModulePlugin)pluginManager.getPlugin(serverSettingsCache.getServerSettings().getWebModule().getPluginDescriptor().getPluginClassName(),true);
      }
    }
  finally {
      ses.close();
    }
    Integer protocolBuffersPort=getServerSettingsCache().getServerSettings().getProtocolBuffersPort();
    if (protocolBuffersPort >= 1 && protocolBuffersPort <= 65535) {
      try {
        protocolBuffersServer=new ProtocolBuffersServer(protocolBuffersMetaData,serviceFactory,servicesMap,protocolBuffersPort);
        protocolBuffersServer.start();
      }
 catch (      Exception e) {
        LOGGER.error("String_Node_Str",e);
      }
    }
    bimServerClientFactory=new DirectBimServerClientFactory<ServiceInterface>(serverSettingsCache.getServerSettings().getSiteAddress(),serviceFactory,servicesMap,pluginManager,metaDataManager);
    pluginManager.setBimServerClientFactory(bimServerClientFactory);
  }
 catch (  BimserverLockConflictException e) {
    throw new BimserverDatabaseException(e);
  }
catch (  PluginException e) {
    throw new BimserverDatabaseException(e);
  }
}