Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/915#discussion_r157765674
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/enricher/stock/MathAggregatorFunctions.java
 ---
    @@ -118,9 +123,10 @@ public T apply(@Nullable Collection<? extends Number> 
vals) {
                 List<Number> postProcessedVals = new ArrayList<>();
                 int count = 0;
                 if (vals != null) {
    -                for (Number val : vals) { 
    -                    if (val != null) {
    -                        postProcessedVals.add(val);
    +                for (Object val : vals) {
    +                    Maybe<Number> coercedVal = 
TypeCoercions.tryCoerce(val, Number.class);
    +                    if (coercedVal.isPresentAndNonNull()) {
    +                        postProcessedVals.add(coercedVal.get());
                             count++;
                         } else if (defaultValueForUnreportedSensors != null) {
    --- End diff --
    
    worth a `log.warn` saying the value if not coercible?
    
    ```
    } else {
      if (val!=null) {
        log.warn("Input to numeric aggregator is not a number: "+val+" 
("+val.getClass+")");
      }
      if (defaultValueForUnrepoertedSensors != null) {
        ...
      }
    }
    ```


---

Reply via email to