wttech / AEM-Rules-for-SonarQube

SonarQube plugin with set of rules detecting possible bugs and bad smells specific for AEM development.
Apache License 2.0
112 stars 51 forks source link

Session should be logged out in finally block. #241

Open ramcharankavvamp opened 4 months ago

ramcharankavvamp commented 4 months ago

We defined and signedout session in finally block from EventListener Activate method, But it is always reporting from cloud manger Session should be logged out in finally block.
@Activate public void activate(ComponentContext context) throws CustomActivationException { Session adminSession=null;

 try {
     adminSession = repository.loginService("xyz",null);
     observationManager=adminSession.getWorkspace().getObservationManager();
     observationManager.addEventListener(
      this, //handler
      Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED, //binary combination of event types
      "xyz/xyz/xyz", //path
      true, //is Deep?
      null, //uuids filter
      null, //nodetypes filter
      false);

 } catch (RepositoryException e){
  logger.error("unable to register session{}",e);
 } finally {         
              if(adminSession !=null){
         adminSession.logout();
         adminSession = null;
      }
 }
}

Please help for logout the adminSession in finally block from cloudmanager report.

Thanks