Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8312481

Returning null as Optional from FindSink.OfRef

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P5 P5
    • None
    • None
    • core-libs

      SonarCloud reports an oddity in `java.util.stream.FindOps.FindSink.OfRef.get()`

      ```
                  @Override
                  public Optional<T> get() {
                      return hasValue ? Optional.of(value) : null;
                  }
      ```

      The method return type is Optional, but it returns `null`.

      Looks like a minor overlook, as similar code in ReduceOps returns Optional.empty(). There might be other implications to this.

            shade Aleksey Shipilev
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: