svn commit: r1811421 - /ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthenticationComparator.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1811421 - /ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthenticationComparator.java

mbrohl
Author: mbrohl
Date: Sat Oct  7 13:49:20 2017
New Revision: 1811421

URL: http://svn.apache.org/viewvc?rev=1811421&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.common.authentication.
(OFBIZ-9627)

Thanks Dennis Balkir for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthenticationComparator.java

Modified: ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthenticationComparator.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthenticationComparator.java?rev=1811421&r1=1811420&r2=1811421&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthenticationComparator.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/common/src/main/java/org/apache/ofbiz/common/authentication/AuthenticationComparator.java Sat Oct  7 13:49:20 2017
@@ -65,14 +65,13 @@ public class AuthenticationComparator im
      *                            being compared by this Comparator.
      */
     public int compare(Authenticator a1, Authenticator a2) {
-        if (a1.getWeight() < a2.getWeight()) {
-            return -1;
-        } else if (a1.getWeight() > a2.getWeight()) {
-            return 1;
-        } else if (!a1.getClass().equals(a2.getClass())) {
+        int comp = Float.compare(a1.getWeight(), a2.getWeight());
+        if (comp != 0) {
+            return (int) Math.signum(comp);
+        }
+        if (!a1.getClass().equals(a2.getClass())) {
             return -1;
-        } else {
-            return a1.getClass().getName().compareTo(a2.getClass().getName());
         }
+        return a1.getClass().getName().compareTo(a2.getClass().getName());
     }
 }