Deprecate MongoIterable#forEach

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 3.9.0
    • Affects Version/s: None
    • Component/s: API
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The forEach(Block<? super TResult> block) method on MongoIterable conflicts with the default forEach method added to java.lang.Iterable in Java 8. If you try to use either with a lambda expression you get a compiler error which forces you to cast the lambda to either Block or Consumer, which is not intuitive.

      The default forEach method in Iterable, though, is dangerous to use with MongoIterable because it's not possible for it to force the MongoCursor to be closed in the case where Consumer.accept throws an exception, but in scope of JAVA-2010 we plan to address that. Given that, it makes sense to deprecate MongoIterable#forEach(Block<? super TResult> block) so that it can be removed in the next major release and users will stop getting the compiler error.

              Assignee:
              Jeffrey Yemin
              Reporter:
              Jeffrey Yemin
              None
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: