From aa4c13492251a4dfd7e8449435f5eebd2eac7e40 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Fri, 2 Jun 2017 14:51:27 -0400 Subject: [PATCH] GUACAMOLE-102: Remove unnecessary checks for weight value in the compare function. --- .../RestrictedGuacamoleTunnelService.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java index d1b491296..56d2f5bac 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java @@ -187,21 +187,10 @@ public class RestrictedGuacamoleTunnelService @Override public int compare(ModeledConnection a, ModeledConnection b) { - - int weightA, weightB; - // Check if weight of a is non-null and retrieve it. - if (a.getConnectionWeight().intValue() > 0) - weightA = a.getConnectionWeight().intValue(); - // In all other cases assign 1 for sorting. - else - weightA = 1; - // Check if weight of b is null, assign 1 if it is. - if (b.getConnectionWeight().intValue() > 0) - weightB = b.getConnectionWeight().intValue(); - // In all other cases assign 1 for sorting. - else - weightB = 1; + // Get connection weight for the two systems being compared. + int weightA = a.getConnectionWeight().intValue(); + int weightB = b.getConnectionWeight().intValue(); // Get current active connections, add 1 to both to avoid calculations with 0. int connsA = getActiveConnections(a).size() + 1;