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 91dd42c43..56cf4ac46 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 @@ -175,8 +175,8 @@ public class ConnectionModel extends ChildObjectModel { * Sets the connection weight. * * @param connectionWeight - * The weight of the connection. null is acceptable, -1 indicates the - * connection should not be used. + * The weight of the connection. null is acceptable, negative values + * indicate that the connection should not be used. */ public void setConnectionWeight(Integer connectionWeight) { this.connectionWeight = 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 8cc660545..3db47c660 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,7 +190,11 @@ public class RestrictedGuacamoleTunnelService logger.debug("Calculating weights for connections {} and {}.", a.getName(), b.getName()); int cw = 0; int weightA = a.getConnectionWeight(); + if (weightA == null) + weightA = 0; int weightB = b.getConnectionWeight(); + if (weightB == null) + weightB = 0; int connsA = getActiveConnections(a).size(); int connsB = getActiveConnections(b).size(); logger.debug("Connection {} has computed weight of {}.", a.getName(), connsA * 10000 / weightA); @@ -208,8 +212,8 @@ public class RestrictedGuacamoleTunnelService // Return the first unreserved connection for (ModeledConnection connection : sortedConnections) { - // If connection weight is negative, this host is disabled and should not be used. - if (connection.getConnectionWeight() < 0) + // If connection weight is zero or negative, this host is disabled and should not be used. + if (connection.getConnectionWeight() < 1) continue; // Attempt to aquire connection according to per-user limits