[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 aledsage 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 --
    I think we should fail-fast if you pass in null. The caller has asked to change the exception supplier, and we've ignored their request without telling them of the problem.
    This kind of null check just leads to more `NullPointerException`s later in the code paths, or more null checks later (which coders/reviewers would not expect to have to do when using `Maybe` or `Optional`).