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

getParameterValues returns String[0] if there is a single value without a comma

    Details

      Description

      When developing I needed to get parameters of unknown length and noticed this problem when getting a single value.

      This is the cause:

      https://github.com/liferay/liferay-portal/blob/master/portal-service/src/com/liferay/portal/kernel/util/ParamUtil.java

      ParamUtil.getParameterValues, line 752:

      if (values.length == 1) {
      return StringUtil.split(values[0]);
      }

      If there is a single value without a comma, the split will return String[0].

      Possible fix (I thought about it while writing this - not tested):
      Check if value[0] contains a comma.

      if (values.length == 1 && values[0].contains(StringPool.COMMA)) {
      return StringUtil.split(values[0]);
      }

      Cheers

        Attachments

          Activity

            People

            • Assignee:
              michael.saechang Michael Saechang
              Reporter:
              ilshira Shira Rand (Inactive)
              Participants of an Issue:
              Recent user:
              Esther Sanz
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                5 years, 48 weeks, 1 day ago

                Packages

                Version Package