Program: 160531
Project: 160531
Buggy source:
private P getBimServerClient(String serviceIdentifier,String profileIdentifier,String apiUrl,String token){
  ServiceMapInterface serviceMapInterface=new ServiceMap(bimServer,null,AccessMethod.JSON);
  serviceMapInterface.add(Bimsie1RemoteServiceInterface.class,internalRemoteServiceInterfaces.get(serviceIdentifier));
  P p=new P();
  final InternalChannel internalChannel=new InternalChannel(bimServer.getServiceFactory(),bimServer.getServicesMap());
  try {
    internalChannel.connect(new SimpleTokenHolder());
  }
 catch (  ChannelConnectionException e) {
    LOGGER.error("String_Node_Str",e);
  }
  try {
    DatabaseSession session=bimServer.getDatabase().createSession();
    try {
      long profileId=Long.parseLong(profileIdentifier);
      EClass eClassForOid=session.getEClassForOid(profileId);
      InternalServicePluginConfiguration internalServicePluginConfiguration=null;
      if (eClassForOid == StorePackage.eINSTANCE.getInternalServicePluginConfiguration()) {
        internalServicePluginConfiguration=session.get(profileId,Query.getDefault());
      }
 else       if (eClassForOid == StorePackage.eINSTANCE.getService()) {
        Service service=session.get(profileId,Query.getDefault());
        internalServicePluginConfiguration=service.getInternalService();
      }
 else {
        throw new RuntimeException("String_Node_Str");
      }
      final SObjectType settings=bimServer.getSConverter().convertToSObject(internalServicePluginConfiguration.getSettings());
      final InternalServicePluginConfiguration finalInternalServicePluginConfiguration=internalServicePluginConfiguration;
      BimServerClientInterface bimServerClient=null;
      if (apiUrl == null) {
        bimServerClient=bimServer.getBimServerClientFactory().create(new TokenAuthentication(token));
      }
 else {
        bimServerClient=new JsonBimServerClientFactory(apiUrl).create(new TokenAuthentication(token));
      }
      p.client=bimServerClient;
      p.settings=settings;
      p.configurationId=finalInternalServicePluginConfiguration.getOid();
      return p;
    }
 catch (    BimserverDatabaseException e) {
      e.printStackTrace();
    }
catch (    ServiceException e) {
      e.printStackTrace();
    }
catch (    ChannelConnectionException e) {
      e.printStackTrace();
    }
 finally {
      session.close();
    }
  }
  finally {
  }
  return null;
}

Fixed version (ground truth):
private P getBimServerClient(String serviceIdentifier,String profileIdentifier,String apiUrl,String token){
  ServiceMapInterface serviceMapInterface=new ServiceMap(bimServer,null,AccessMethod.JSON);
  serviceMapInterface.add(Bimsie1RemoteServiceInterface.class,internalRemoteServiceInterfaces.get(serviceIdentifier));
  P p=new P();
  final InternalChannel internalChannel=new InternalChannel(bimServer.getServiceFactory(),bimServer.getServicesMap());
  try {
    internalChannel.connect(new SimpleTokenHolder());
  }
 catch (  ChannelConnectionException e) {
    LOGGER.error("String_Node_Str",e);
  }
  try {
    DatabaseSession session=bimServer.getDatabase().createSession();
    try {
      long profileId=Long.parseLong(profileIdentifier);
      EClass eClassForOid=session.getEClassForOid(profileId);
      InternalServicePluginConfiguration internalServicePluginConfiguration=null;
      if (eClassForOid == StorePackage.eINSTANCE.getInternalServicePluginConfiguration()) {
        internalServicePluginConfiguration=session.get(profileId,Query.getDefault());
      }
 else       if (eClassForOid == StorePackage.eINSTANCE.getService()) {
        Service service=session.get(profileId,Query.getDefault());
        internalServicePluginConfiguration=service.getInternalService();
      }
 else {
        throw new RuntimeException("String_Node_Str");
      }
      final SObjectType settings=bimServer.getSConverter().convertToSObject(internalServicePluginConfiguration.getSettings());
      final InternalServicePluginConfiguration finalInternalServicePluginConfiguration=internalServicePluginConfiguration;
      BimServerClientInterface bimServerClient=null;
      BimServerClientFactory factory=null;
      if (apiUrl == null) {
        factory=bimServer.getBimServerClientFactory();
      }
 else {
        if (factories.containsKey(apiUrl)) {
          factory=factories.get(apiUrl);
        }
 else {
          FileBasedReflectorFactoryBuilder reflectorBuilder=new FileBasedReflectorFactoryBuilder();
          ReflectorFactory reflectorFactory=reflectorBuilder.newReflectorFactory();
          factory=new JsonBimServerClientFactory(apiUrl,bimServer.getServicesMap(),new JsonSocketReflectorFactory(bimServer.getServicesMap()),reflectorFactory);
          factories.put(apiUrl,factory);
        }
      }
      bimServerClient=factory.create(new TokenAuthentication(token));
      p.client=bimServerClient;
      p.settings=settings;
      p.configurationId=finalInternalServicePluginConfiguration.getOid();
      return p;
    }
 catch (    BimserverDatabaseException e) {
      LOGGER.error("String_Node_Str",e);
    }
catch (    ServiceException e) {
      LOGGER.error("String_Node_Str",e);
    }
catch (    ChannelConnectionException e) {
      LOGGER.error("String_Node_Str",e);
    }
 finally {
      session.close();
    }
  }
  finally {
  }
  return null;
}