Github user mike-jumper commented on a diff in the pull request:
https://github.com/apache/incubator-guacamole-client/pull/161#discussion_r119914637
--- Diff:
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java
---
@@ -179,9 +187,27 @@ protected ModeledConnection
acquire(RemoteAuthenticatedUser user,
@Override
public int compare(ModeledConnection a, ModeledConnection b) {
-
- return getActiveConnections(a).size()
- - getActiveConnections(b).size();
+
+ int weightA, weightB;
+ // Check if weight of a is non-null and retrieve it.
+ if (a.getConnectionWeight() != null &&
a.getConnectionWeight().intValue() > 0)
--- End diff --
Checking for `null`, using a default value, etc. seems the sort of logic
that should be within `ModeledConnection`, rather than repeated here. That way
you could simply call `a.getWeight()` or `a.getConnectionWeight()` and it will
always just work?
Only the underlying model object (and the code applying attribute changes)
need actually worry about such internal concerns.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---