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

java.util.Pattern.matcher function throws a NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 7
    • core-libs

      A DESCRIPTION OF THE REQUEST :
      java.util.Pattern.matcher function throws a NullPointerException if the argument is NULL.

      JUSTIFICATION :
      This functions shouldn't throw NPE, just do its work as the argument is a text that doesn't matches...

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The works of this function should be the same as if the argument is a text that doesn't matches with the pattern
      ACTUAL -
      NullPointerException

      ---------- BEGIN SOURCE ----------
      private final static String REGEXP_TEST_EMAIL = " ^blabla(\\.)?(ui)?test(\\.)?(child|teen|adult)?[0-9]*(\\+)?[a-zA-Z0-9]*@gmail.com " ;
      private static Pattern emailPattern = Pattern.compile(REGEXP_TEST_EMAIL);

      String email = null;
      Matcher matcher = emailPattern.matcher(emailAddress);
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: