From 58637818ca0c6e88bcd2fcd55f786bee509f5bdc Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Fri, 2 Jun 2017 14:47:15 -0400 Subject: [PATCH] GUACAMOLE-102: Move null check for connection weight to the connection model. --- .../guacamole/auth/jdbc/connection/ConnectionModel.java | 2 ++ .../auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java index 56cf4ac46..69ef4c311 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java @@ -191,6 +191,8 @@ public class ConnectionModel extends ChildObjectModel { * -1 indicates that the system is unavailable. */ public Integer getConnectionWeight() { + if (connectionWeight == null) + return 1; return connectionWeight; } 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 71d4f7f37..d1b491296 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 @@ -190,14 +190,14 @@ public class RestrictedGuacamoleTunnelService int weightA, weightB; // Check if weight of a is non-null and retrieve it. - if (a.getConnectionWeight() != null && a.getConnectionWeight().intValue() > 0) + 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() != null && b.getConnectionWeight().intValue() > 0) + if (b.getConnectionWeight().intValue() > 0) weightB = b.getConnectionWeight().intValue(); // In all other cases assign 1 for sorting. else