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

java for-each loop should handle nulls cleanly.

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 15
    • Fix Version/s: None
    • Component/s: specification
    • Labels:
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      A DESCRIPTION OF THE PROBLEM :
      java for-each loop throws a NullPointerException when a null collection is passed in. Instead, it should act like it does for an empty collection and just exit the loop cleanly. This would reduce a lot of boilerplate code that either has to check for null values, use Optionals, or the use of third party software (eg apache.commons).


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sswsharm swati sharma
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: