GUACAMOLE-102: Move null check for connection weight to the connection model.

This commit is contained in:
Nick Couchman
2017-06-02 14:47:15 -04:00
committed by Nick Couchman
parent 4033e097c7
commit 58637818ca
2 changed files with 4 additions and 2 deletions

View File

@@ -191,6 +191,8 @@ public class ConnectionModel extends ChildObjectModel {
* -1 indicates that the system is unavailable. * -1 indicates that the system is unavailable.
*/ */
public Integer getConnectionWeight() { public Integer getConnectionWeight() {
if (connectionWeight == null)
return 1;
return connectionWeight; return connectionWeight;
} }

View File

@@ -190,14 +190,14 @@ public class RestrictedGuacamoleTunnelService
int weightA, weightB; int weightA, weightB;
// Check if weight of a is non-null and retrieve it. // 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(); weightA = a.getConnectionWeight().intValue();
// In all other cases assign 1 for sorting. // In all other cases assign 1 for sorting.
else else
weightA = 1; weightA = 1;
// Check if weight of b is null, assign 1 if it is. // 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(); weightB = b.getConnectionWeight().intValue();
// In all other cases assign 1 for sorting. // In all other cases assign 1 for sorting.
else else