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

Setting an empty string for a multi-value field of an OSGI config does not result in an empty array

    Details

      Description

      Context
      After discussing with the Core Infra team, we determined that when setting a multi-valued field with the value: empty string, the resulting field should return an empty array.

      However, for the current behavior, the result field returns an array with a single item that contains an empty string.

      Steps to Reproduce

      • Startup Liferay
      • Create an OSGI Config file in osgi/configs for Redirect URLs with file name: com.liferay.redirect.internal.configuration.RedirectURLConfiguration.config
      • Scenario A: Test setting allowedDomains field as an empty array
        • Add the following to the created config file:
          allowedDomains=[]
          
        • Wait 3-5 seconds for Liferay to use the updated config file
        • Run the provided groovy script below to check the value of allowedDomains
        • Notice the script results show that the value is an empty array
      • Scenario B: Test setting allowedDomains field with an empty string
        allowedDomains=""
        
        • Wait 3-5 seconds for Liferay to use the updated config file
        • Run the provided groovy script below to check the value of allowedDomains

      Expected Result
      The script results show that the value is an empty array

      Actual Result
      The script results show that the value is an array containing one item that contains an empty string.


      Groovy Script: Check the value of allowedDomains for the Redirect URLs Configuration

      import org.osgi.framework.FrameworkUtil
      import com.liferay.portal.kernel.util.PortalUtil
      import com.liferay.portal.scripting.groovy.internal.GroovyExecutor
      
      company = PortalUtil.getCompany(actionRequest)
      
      redirectURLSettings = getService(com.liferay.portal.kernel.redirect.RedirectURLSettings.class)
      allowedDomains = redirectURLSettings.getAllowedDomains(company.getCompanyId())
      
      println "allowedDomains"
      
      if (allowedDomains == null) {
          println "- is null"
      }
      else if (allowedDomains.size() > 0) {
          println "- is an array with size: " + allowedDomains.size()
      
          if ((allowedDomains[0] instanceof String) && allowedDomains[0].isEmpty()) {
              println "- first object is an empty string"
          }
      }
      else {
          println "- is an empty array"
      }
      
      
      def getService(className) {
          def bundle = FrameworkUtil.getBundle(GroovyExecutor.class);
      
          def bundleContext = bundle.getBundleContext();
      
          def serviceReferences =
              bundleContext.getServiceReferences(className, null);
      
          def service = bundleContext.getService(serviceReferences[0]);
      
          return service;
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              summer.zhang Summer Zhang
              Reporter:
              eric.yan Eric Yan
              Participants of an Issue:
              Recent user:
              Felipe Lins
              Engineering Assignee:
              Eric Yan
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                15 weeks, 2 days ago

                  Packages

                  Version Package
                  7.4.3.16 CE GA16
                  7.4.3.22 CE GA22
                  7.4.3.23 CE GA23
                  Master