You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by st...@apache.org on 2018/05/29 20:59:31 UTC

svn commit: r1832483 - /geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/ConfigImpl.java

Author: struberg
Date: Tue May 29 20:59:31 2018
New Revision: 1832483

URL: http://svn.apache.org/viewvc?rev=1832483&view=rev
Log:
fix sorting of ConfigSources if they have the same ordinal

Modified:
    geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/ConfigImpl.java

Modified: geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/ConfigImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/ConfigImpl.java?rev=1832483&r1=1832482&r2=1832483&view=diff
==============================================================================
--- geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/ConfigImpl.java (original)
+++ geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/ConfigImpl.java Tue May 29 20:59:31 2018
@@ -286,11 +286,20 @@ public class ConfigImpl implements Confi
         }
     }
 
+    /**
+     * ConfigSources are sorted with descending ordinal.
+     * If 2 ConfigSources have the same ordinal, then they get sorted according to their name, alphabetically.
+     */
     private List<ConfigSource> sortDescending(List<ConfigSource> configSources) {
         configSources.sort(
-                (configSource1, configSource2) -> (configSource1.getOrdinal() > configSource2.getOrdinal()) ? -1 : 1);
+                (configSource1, configSource2) -> {
+                    int compare = Integer.compare(configSource2.getOrdinal(), configSource1.getOrdinal());
+                    if (compare == 0) {
+                        return configSource1.getName().compareTo(configSource2.getName());
+                    }
+                    return compare;
+                });
         return configSources;
-
     }
 
     private Type getTypeOfConverter(Class clazz) {