Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-11762

Possible NPE on fallbackCredentials in PluginUserSession

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • 13.1.0
    • None
    • None
    • Pulsar
    • Platform 203 - Beanless 1

    Description

      For some reason not completely clear to me, the code below in PluginUserSession:

      if (session == null) {
                  Main main = (Main)Application.get();
                  if (fallbackCredentials == null) {
                      try {
                          main.getRepository(); // side effect of reinitializing fallback credentials
                      } catch (RepositoryException ignored) {
                      }
                  }
                  if (fallbackSession == null) {
                      try {
                          fallbackSession = JcrSessionModel.login(fallbackCredentials);
                      } catch (RepositoryException e) {
                          log.warn("Cannot login fallback session: " + e.getMessage());
                      }
                  }
      

      can result in fallbackCredentials still being null, while main.getRepository() should set the fallback credentials (static class member of PluginUserSession). That this happens during tests is not strange since 'main' gets subclassed in tests which do not set the fallbackCredentials

      Since PluginUserSession is serializable, it should not rely in static class variables imho. Hence, improve the code to avoid odd possible NPE's

      Attachments

        Activity

          People

            Unassigned Unassigned
            aschrijvers Ard Schrijvers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: