Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Java API - Approvals objects ordering behaviour is different in two instances with same version

Petr Vaníček
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2022

Hello,

we have some kind of problem with aprrovals object with our Scriptrunner listeners. In our case on TEST env we getting different ordering than on our PROD env.

list = ApprovalService.getApprovals(ApplicationUser, Query)

We are using list[0].getId().toString(), but in one case we get first object from list and in second case we get last object.

 

in TEST: PagedResponse from list we get ordering from first approval (L1) to last approval (L2)

in PROD: PagedResponse from list we get ordering from last approval (L2) to first approval (L1)

Environments are with same versions of JSW,JSM and Scriptrunner.

Do you know why is this happening?

2 answers

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
February 23, 2022

Hi @Petr Vaníček

You could try to run a sort() command in your list for bot instances to ensure that the values are sorted accordingly. For example:-

list.sort { it.created }[0].getId().toString()

I hope this helps to answer your question. :)

Thank you and Kind regards,

Ram

0 votes
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2022

If both test & prod are exact same versions then I would assume it's not that there is any difference in the API.

Can you do a list.getClass() and see what the API returns? If it is an ArrayList then that does not guarantee the order of elements. Perhaps you might need to convert it to your own LinkedList based on some sorting mechanism. I can only see the javadocs for ApprovalService but can't dig into the source code right now to see how it fetches those approvals or which list subclass it uses.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events