Details
-
Bug
-
Status: Closed
-
Resolution: Fixed
-
7.1.X, 7.2.X, 7.3.X, Master
-
7.3.x, 7.2.x, 7.1.x
-
Committed
-
3
Description
An ArrayIndexOutOfBoundsException is thrown in headless api if you sort using a non-localizable DDM field
Steps to reproduce
- Create a webcontent structure
- Add a field in that structure and in the advanced setion, set:
- "field reference" to 'myField' value
- "localizable" to disabled
- Get the ID of the created structure
- 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
- 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) ~[?:?]
- Expected behavior: No error is produced and an empty array is returned
Attachments
Issue Links
- Discovered while testing
-
LPS-136137 Unable to use DDM field in Custom Facet when it's not localizable: ArrayIndexOutOfBoundsException
- Closed
- is related to
-
LPS-118503 Filter and sort in contentFields headless delivery API does not work
- Closed