diff --git a/src/main/java/org/elasticsearch/rest/RestController.java b/src/main/java/org/elasticsearch/rest/RestController.java index de8c7c66647..6dcb72c37d3 100644 --- a/src/main/java/org/elasticsearch/rest/RestController.java +++ b/src/main/java/org/elasticsearch/rest/RestController.java @@ -86,7 +86,7 @@ public class RestController extends AbstractLifecycleComponent { Arrays.sort(copy, new Comparator() { @Override public int compare(RestFilter o1, RestFilter o2) { - return o2.order() - o1.order(); + return Integer.compare(o1.order(), o2.order()); } }); filters = copy; diff --git a/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java b/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java index 3e84600b0b7..334a9783859 100644 --- a/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java +++ b/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java @@ -60,7 +60,7 @@ public class RestFilterChainTests extends ElasticsearchTestCase { Collections.sort(restFiltersByOrder, new Comparator() { @Override public int compare(RestFilter o1, RestFilter o2) { - return Integer.compare(o2.order(), o1.order()); + return Integer.compare(o1.order(), o2.order()); } });