diff --git a/modules/core/src/main/java/org/apache/synapse/api/ApiUtils.java b/modules/core/src/main/java/org/apache/synapse/api/ApiUtils.java index 7533f2b6a2..15adf22b1c 100644 --- a/modules/core/src/main/java/org/apache/synapse/api/ApiUtils.java +++ b/modules/core/src/main/java/org/apache/synapse/api/ApiUtils.java @@ -43,7 +43,9 @@ import java.net.URL; import java.net.URLDecoder; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; +import java.util.LinkedList; import java.util.Map; import java.util.LinkedHashSet; import java.util.List; @@ -184,13 +186,17 @@ public static boolean isBound(Resource resource, MessageContext synCtx) { } public static Set getAcceptableResources(Map resources, MessageContext synCtx) { - Set acceptableResources = new LinkedHashSet(); + List acceptableResourcesList = new LinkedList<>(); for (Resource r : resources.values()) { if (isBound(r, synCtx) && r.canProcess(synCtx)) { - acceptableResources.add(r); + if (Arrays.asList(r.getMethods()).contains(RESTConstants.METHOD_OPTIONS)) { + acceptableResourcesList.add(0, r); + } else { + acceptableResourcesList.add(r); + } } } - return acceptableResources; + return new LinkedHashSet(acceptableResourcesList); } /**