[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] brooklyn-server pull request #982: Improve coercions esp with generics

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

    --- Diff: utils/common/src/main/java/org/apache/brooklyn/util/guava/Maybe.java ---
    @@ -365,7 +365,7 @@ public RuntimeException getException() {
             public static <T> Maybe<T> changeExceptionSupplier(Maybe<T> original, Function<AnyExceptionSupplier<?>,Supplier<? extends RuntimeException>> transform) {
    -            if (original.isPresent()) return original;
    +            if (original==null || original.isPresent()) return original;
    --- End diff --
    semantics of method were to change exception supplier _if_ it's absent, and do nothing if it's present.  logical extension of that is also to do nothing if it's null IMO.  if we were to "fail fast" we are applying a particular dogma that says a `Maybe` shouldn't be null, which might be helpful in some situations but it gets in the way in others.  if the `Maybe` being null is a problem the user will likely discover that, and it's not much helpful if we discover that slightly earlier.  more helpful i think to allow callers who might have a null Maybe.