Github user mike-jumper commented on a diff in the pull request:

    
https://github.com/apache/incubator-guacamole-client/pull/161#discussion_r120202144
  
    --- Diff: 
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
 ---
    @@ -165,6 +172,33 @@ public Integer getMaxConnectionsPerUser() {
         }
     
         /**
    +     * Sets the connection weight.
    +     *
    +     * @param connectionWeight
    +     *     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;
    +    }
    +
    +    /**
    +     * Returns the connection weight used in calculating the
    +     * weighted algorithms.
    +     *
    +     * @return
    +     *     The connection weight as an int.  If the weight is
    +     *     null a default weight of 1 is returned.  Zero and
    +     *     negative numbers are used to indicate the system is
    +     *     unavailable.
    +     */
    +    public int getConnectionWeight() {
    +        if (connectionWeight == null)
    +            return 1;
    +        return connectionWeight.intValue();
    --- End diff --
    
    Right so, to be clear:
    
    1. It makes sense that `getConnectionWeight()` of `ConnectionModel` returns 
`Integer`. Since this is a model object and the value can indeed be `null`, 
this actually should be the case.
    2. Within `ModeledConnection`, a higher-level object which is expected to 
abstract away some of the low level detail, it makes sense for 
`getConnectionWeight()` to return `int`, automatically handling things like 
that `null` check and the default value.
    
    It's definitely not safe to simply keep this particular function as 
returning `int` when `connectionWeight` can be `null`, but that's OK because 
this particular function should be returning `Integer`. It's the 
`ModeledConnection` version that should handle the other aspects, always 
returning a sensible `int`.


---
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.
---

Reply via email to