[
https://issues.apache.org/jira/browse/SYNAPSE-1002?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ravi Undupitiya closed SYNAPSE-1002.
------------------------------------
Resolution: Invalid
> API's with overlapping path segments are dispatched in a non-deterministic
> manner when they are updated
> --------------------------------------------------------------------------------------------------------
>
> Key: SYNAPSE-1002
> URL: https://issues.apache.org/jira/browse/SYNAPSE-1002
> Project: Synapse
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.1
> Reporter: Ravi Undupitiya
> Assignee: Hiranya Jayathilaka
> Labels: API, Non-deterministic
> Fix For: 2.1, FUTURE
>
> Attachments: api-nondeterministic-fix.diff
>
>
> i) Create the below API
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <api name="testAPI" context="/services/abc/testContext">
> <resource methods="POST GET" uri-template="/{+username}">
> <inSequence>
> <log>
> <property name="======>;"
> expression="get-property("uri.var.username")" />
> </log>
> <header name="To" action="remove"/>
> <property name="RESPONSE" value="true" scope="default"
> type="STRING"/>
> <property name="NO_ENTITY_BODY" scope="axis2"
> action="remove"/>
> <send/>
> </inSequence>
> <outSequence />
> </resource>
> <resource methods="POST GET" uri-template="/{+username}/foo">
> <inSequence>
> <log>
> <property name="======>; foo"
> expression="get-property("uri.var.username")" />
> </log>
> <header name="To" action="remove"/>
> <property name="RESPONSE" value="true" scope="default"
> type="STRING"/>
> <property name="NO_ENTITY_BODY" scope="axis2"
> action="remove"/>
> <send/>
> </inSequence>
> <outSequence />
> </resource>
> </api>
> {code}
> 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.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]