i) Create the below API
2) Send the request following and you'll get the log entry as "response, ======>; = esb" .
curl -v http://localhost:8280/services/abc/testContext/esb -H "Content-Type: application/xml" -d '<abc/>' -X POST
3) Send the request following and you will get the log entry as "request, ======>; foo = esb"
curl -v http://localhost:8280/services/abc/testContext/esb/foo -H "Content-Type: application/xml" -d '<abc/>' -X POST
4) Update one of the resources.
5) Note that the resource selection behavior is not deterministic.
This non-deterministic dispatching can be an issue and it is happening due to the use of a Set as the collection that holds resources. To fix this issue we can use an ordered set like SortedSet however this provides log(n) time for add operations and since this set is created for every request, a better solution is to use LinkedHashSet which has better performance. However LinkedHashSet will only guarantee insertion order (so if the resources are swapped in the configuration, we will again see a different behavior).
A similar fix has been done to maintain resource ordering by using LinkedHashMap which also only guarantees insertion order.
Based on this, I've attach a diff that uses a LinkedHashSet to overcome this issue.