Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fix for #83 sort functions inside existing synchronized block.
Browse files Browse the repository at this point in the history
Rankings of exposed functions on the REST mapper are treated as final so
they can be sorted when added rather than for each request.

Signed-off-by: Elias N Vasylenko <[email protected]>
  • Loading branch information
Sophos-Elias-Vasylenko committed Mar 23, 2017
1 parent a6cccee commit 8f25091
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public synchronized void addResource(REST resource, int ranking) {

Function function = new Function(resource, m, verb, path, ranking);
functions.add(function.getName(), function);

Collections.sort(functions.get(function.getName()),
(a, b) -> Integer.compare(a.ranking, b.ranking));
}
endpoints.add(resource);
}
Expand Down Expand Up @@ -259,9 +262,6 @@ public boolean execute(HttpServletRequest rq, HttpServletResponse rsp)
throw new FileNotFoundException("No such method " + name + "/"
+ cardinality + ". Available: " + functions);

Collections.sort(candidates,
(a, b) -> Integer.compare(a.ranking, b.ranking));

//
// All values are arrays, turn them into singletons when
// they have one element
Expand Down

0 comments on commit 8f25091

Please sign in to comment.