Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-9424

Use of new site API could lead to NPE with boolean parameters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • 4.2.0
    • None
    • None
    • None
    • 4.2 M7

      In org.ametys.plugins.pagesubscription.observer.AbstractPageSubscriptionObserver we get a site parameter as boolean

      protected boolean isNotificationEnabled(Page page)
      {
              Site site = page.getSite();
              return site.getValue(getSiteParameterId());
       }
      

      This code leads to a NPE if the site parameter is not valued, because getValue return null.
      In this case, the observer failed and the content is not availble in live workspace.

      Waiting for REPOSITORY-402, all calls to site.getValue should be verified and fix with

      protected boolean isNotificationEnabled(Page page)
      {
              Site site = page.getSite();
              // FIXME REPOSITORY-402 Missing a ModelAwareDataHolder#getValue method with a default value
              return BooleanUtils.isTrue(site.getValue(getSiteParameterId()));
      }
      

            Unassigned Unassigned
            laurence Laurence Aumeunier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: