Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-116151

Handle null condition for locale in OrganizationTypeConfigurationModelListener.java

    Details

      Description

      Calling to

      ResourceBundleUtil.getBundle("content.Language", LocaleThreadLocal.getThemeDisplayLocale(), getClass());


      causes a NPE when

      LocaleThreadLocal.getThemeDisplayLocale()

      is null:

      Caused by: java.lang.NullPointerException
              at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1618)
              at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1593)
              at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:1509)
              at com.liferay.portal.kernel.util.ResourceBundleUtil._getBundle(ResourceBundleUtil.java:242)
              at com.liferay.portal.kernel.util.ResourceBundleUtil.getBundle(ResourceBundleUtil.java:96)
              at com.liferay.portal.kernel.util.ResourceBundleUtil.getBundle(ResourceBundleUtil.java:88)
              at com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener._getResourceBundle(OrganizationTypeConfigurationModelListener.java:62)
              at com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener._validateUniqueConfiguration(OrganizationTypeConfigurationModelListener.java:100)
              at com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener.onBeforeSave(OrganizationTypeConfigurationModelListener.java:52)
              ... 69 more
      

      Steps to reproduce

      1. Make a copy of the file
        osgi/configs/com.liferay.organizations.internal.configuration.OrganizationTypeConfiguration-default.config

        and rename it. Locate this file out of osgi directory tree. For example:

        /tmp/com.liferay.organizations.internal.configuration.OrganizationTypeConfiguration-foo.config
      2. Start DXP.
      3. Copy
        /tmp/com.liferay.organizations.internal.configuration.OrganizationTypeConfiguration-foo.config

        to osgi/configs/ directory.

      4. Wait some seconds until listener checks the directory.

      Observed behavior

      2021-03-15 11:23:50.803 ERROR [fileinstall-directory-watcher][DirectoryWatcher:687] Unable to install artifact: /liferay-portal/osgi/configs/com.liferay.organizations.internal.configuration.OrganizationTypeConfiguration-foo.config 
      com.liferay.portal.configuration.persistence.listener.ConfigurationModelListenerException: The listener com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener was unable to save configuration com.liferay.organizations.internal.configuration.OrganizationTypeConfiguration: null 
      	at com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener.onBeforeSave(OrganizationTypeConfigurationModelListener.java:56) 
      	at com.liferay.portal.configuration.persistence.internal.ConfigurationPersistenceManager.store(ConfigurationPersistenceManager.java:237) 
      	at org.apache.felix.cm.impl.persistence.PersistenceManagerProxy.store(PersistenceManagerProxy.java:203) 
      	at org.apache.felix.cm.impl.ConfigurationImpl.update(ConfigurationImpl.java:461) 
      	at org.apache.felix.cm.impl.ConfigurationAdapter.update(ConfigurationAdapter.java:145) 
      	at com.liferay.portal.file.install.internal.configuration.ConfigurationFileInstaller.transformURL(ConfigurationFileInstaller.java:141) 
      	at com.liferay.portal.file.install.internal.DirectoryWatcher._install(DirectoryWatcher.java:668) 
      	at com.liferay.portal.file.install.internal.DirectoryWatcher._install(DirectoryWatcher.java:703) 
      	at com.liferay.portal.file.install.internal.DirectoryWatcher._process(DirectoryWatcher.java:998) 
      	at com.liferay.portal.file.install.internal.DirectoryWatcher.run(DirectoryWatcher.java:272) 
      Caused by: java.lang.NullPointerException 
      	at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936) 
      	at com.liferay.portal.kernel.resource.bundle.CacheResourceBundleLoader.loadResourceBundle(CacheResourceBundleLoader.java:58) 
      	at com.liferay.portal.kernel.util.ResourceBundleUtil._getBundle(ResourceBundleUtil.java:221) 
      	at com.liferay.portal.kernel.util.ResourceBundleUtil.getBundle(ResourceBundleUtil.java:95) 
      	at com.liferay.portal.kernel.util.ResourceBundleUtil.getBundle(ResourceBundleUtil.java:87) 
      	at com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener._getResourceBundle(OrganizationTypeConfigurationModelListener.java:62) 
      	at com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener._validateUniqueConfiguration(OrganizationTypeConfigurationModelListener.java:100) 
      	at com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener.onBeforeSave(OrganizationTypeConfigurationModelListener.java:52) 
      	... 9 more 
      

      Expected behavior

      2021-03-15 11:32:10.656 ERROR [fileinstall-directory-watcher][DirectoryWatcher:687] Unable to install artifact: /liferay-portal/osgi/configs/com.liferay.organizations.internal.configuration.OrganizationTypeConfiguration-foo.config 
      com.liferay.portal.configuration.persistence.listener.ConfigurationModelListenerException: The listener com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener was unable to save configuration com.liferay.organizations.internal.configuration.OrganizationTypeConfiguration: There is already an organization type with the name: organization. 
      	at com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener.onBeforeSave(OrganizationTypeConfigurationModelListener.java:56) 
      	at com.liferay.portal.configuration.persistence.internal.ConfigurationPersistenceManager.store(ConfigurationPersistenceManager.java:237) 
      	at org.apache.felix.cm.impl.persistence.PersistenceManagerProxy.store(PersistenceManagerProxy.java:203) 
      	at org.apache.felix.cm.impl.ConfigurationImpl.update(ConfigurationImpl.java:461) 
      	at org.apache.felix.cm.impl.ConfigurationAdapter.update(ConfigurationAdapter.java:145) 
      	at com.liferay.portal.file.install.internal.configuration.ConfigurationFileInstaller.transformURL(ConfigurationFileInstaller.java:141) 
      	at com.liferay.portal.file.install.internal.DirectoryWatcher._install(DirectoryWatcher.java:668) 
      	at com.liferay.portal.file.install.internal.DirectoryWatcher._install(DirectoryWatcher.java:703) 
      	at com.liferay.portal.file.install.internal.DirectoryWatcher._process(DirectoryWatcher.java:998) 
      	at com.liferay.portal.file.install.internal.DirectoryWatcher.run(DirectoryWatcher.java:272) 
      Caused by: java.lang.Exception: There is already an organization type with the name: organization. 
      	at com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener._validateUniqueConfiguration(OrganizationTypeConfigurationModelListener.java:102) 
      	at com.liferay.organizations.internal.configuration.persistence.listener.OrganizationTypeConfigurationModelListener.onBeforeSave(OrganizationTypeConfigurationModelListener.java:52) 
      	... 9 more 
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sharry.shi Sharry Shi
              Reporter:
              sergio.alonso Sergio Alonso
              Participants of an Issue:
              Recent user:
              Sophia Zhang
              Engineering Assignee:
              Sergio Alonso
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                1 year, 15 weeks, 4 days ago

                  Packages

                  Version Package
                  7.2.10 DXP FP12
                  7.2.X
                  7.3.7 CE GA8
                  7.3.10 DXP FP2
                  7.3.X
                  7.4.0 CE GA1 DXP 7,4
                  7.4.13 DXP GA1
                  Master