This repository was archived by the owner on May 28, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
main/java/org/glassfish/jersey/model/internal
test/java/org/glassfish/jersey/process/internal Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 11/*
22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33 *
4- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
4+ * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
55 *
66 * The contents of this file are subject to the terms of either the GNU
77 * General Public License Version 2 only ("GPL") or the Common Development
@@ -66,7 +66,7 @@ public enum Order {
6666 */
6767 DESCENDING (-1 );
6868
69- private int ordering ;
69+ private final int ordering ;
7070
7171 private Order (int ordering ) {
7272 this .ordering = ordering ;
@@ -85,10 +85,10 @@ public RankedComparator(final Order order) {
8585
8686 @ Override
8787 public int compare (final RankedProvider <T > o1 , final RankedProvider <T > o2 ) {
88- return (getPriority (o1 ) - getPriority (o2 )) * order .ordering ;
88+ return (( getPriority (o1 ) > getPriority (o2 )) ? order .ordering : - order . ordering ) ;
8989 }
9090
91- protected int getPriority (RankedProvider <T > rankedProvider ) {
91+ protected int getPriority (final RankedProvider <T > rankedProvider ) {
9292 return rankedProvider .getRank ();
9393 }
9494}
Original file line number Diff line number Diff line change 11/*
22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33 *
4- * Copyright (c) 2012-2014 Oracle and/or its affiliates. All rights reserved.
4+ * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
55 *
66 * The contents of this file are subject to the terms of either the GNU
77 * General Public License Version 2 only ("GPL") or the Common Development
@@ -71,6 +71,8 @@ public void testPriorityComparator() {
7171 list .add (new RankedProvider <Object >(new F100 ()));
7272 list .add (new RankedProvider <Object >(new F200 ()));
7373 list .add (new RankedProvider <Object >(new F200 ()));
74+ list .add (new RankedProvider <Object >(new F_INT_MIN ()));
75+ list .add (new RankedProvider <Object >(new F_INT_MAX ()));
7476 Collections .sort (list , new RankedComparator <Object >(RankedComparator .Order .ASCENDING ));
7577 int max = Integer .MIN_VALUE ;
7678 for (RankedProvider <Object > o : list ) {
@@ -112,4 +114,11 @@ private static class F300 {
112114 private static class F1000 {
113115 }
114116
117+ @ Priority (Integer .MIN_VALUE )
118+ private static class F_INT_MIN {
119+ }
120+
121+ @ Priority (Integer .MAX_VALUE )
122+ private static class F_INT_MAX {
123+ }
115124}
You can’t perform that action at this time.
0 commit comments