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

ArrayIndexOutOfBoundsException in headless api if you sort using a non-localizable DDM field

Details

    Description

      An ArrayIndexOutOfBoundsException is thrown in headless api if you sort using a non-localizable DDM field

      Steps to reproduce

      1. Create a webcontent structure
      2. Add a field in that structure and in the advanced setion, set:
        • "field reference" to 'myField' value
        • "localizable" to disabled
      3. Get the ID of the created structure
      4. Go to the command line and execute:
        curl "http://localhost:8080/o/headless-delivery/v1.0/content-structures/[STRUCTURE_ID]/structured-contents?sort=contentFields%2FmyField" -u '[USER_EMAIL]:[USER_PASSWORD]'

        Replace [STRUCTURE_ID] with the ID of the created structure. Replace the [USER_EMAIL] and [USER_PASSWORD] with the user email and password

      5. Check the log file and the returned data:
        • Expected behavior: No error is produced and an empty array is returned
        • Wrong behavior: An INTERNAL_SERVER_ERROR - Index 3 out of bounds for length 3 error is returned, if you check the log file, an ArrayIndexOutOfBoundsException is thrown in the log file
          2021-08-03 11:24:25.265 ERROR [http-nio-8080-exec-4][WebApplicationExceptionMapper:38] com.liferay.portal.odata.sort.InvalidSortException: Unable to sort by property: contentFields/myField
          com.liferay.portal.odata.sort.InvalidSortException: Unable to sort by property: contentFields/myField
                  at com.liferay.portal.odata.internal.sort.SortParserImpl.lambda$getSortFieldOptional$2(SortParserImpl.java:159) ~[?:?]
                  at java.util.Optional.orElseThrow(Optional.java:408) ~[?:?]
                  at com.liferay.portal.odata.internal.sort.SortParserImpl.getSortFieldOptional(SortParserImpl.java:158) ~[?:?]
                  at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[?:?]
                  at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) ~[?:?]
                  at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?]
                  at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?]
                  at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[?:?]
                  at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
                  at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[?:?]
                  at com.liferay.portal.odata.internal.sort.SortParserImpl.parse(SortParserImpl.java:91) ~[?:?]
                  at com.liferay.portal.vulcan.internal.jaxrs.context.provider.SortContextProvider.createContext(SortContextProvider.java:85) ~[?:?]
                  at com.liferay.portal.vulcan.internal.jaxrs.context.provider.SortContextProvider.createContext(SortContextProvider.java:113) ~[?:?]
                  at com.liferay.portal.vulcan.internal.jaxrs.context.provider.SortContextProvider.createContext(SortContextProvider.java:45) ~[?:?]

      Attachments

        Issue Links

          Activity

            People

              chao.wang Chao Wang
              jorge.diaz Jorge Diaz
              Kiyoshi Lee Kiyoshi Lee
              Jorge Diaz Jorge Diaz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                1 year, 31 weeks, 5 days ago

                Packages

                  Version Package
                  7.1.10 DXP FP26
                  7.1.10.7 SP7
                  7.1.X
                  7.2.10 DXP FP15
                  7.2.X
                  7.3.10.3 DXP SP3
                  7.3.X
                  7.4.13 DXP GA1
                  Master