Commons Validator
  1. Commons Validator
  2. VALIDATOR-252

Performance improvement of DomainValidator by change the regular expression

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4.0 Release
    • Fix Version/s: 1.4.0 Release
    • Component/s: Routines
    • Labels:
      None
    • Environment:

      Windows 2000 Professional, Pentium4 2.4GHz, RAM:512M, Eclipse 3.3m Junit 3.8.1

      Description

      It seemed to take very long time to match the regular expression when long TLD (consists of around 30-characters over TLD) was specified for DomainValidator, this exponential performance will make it appear that the program has hung.

      The match time improves if it is possible to change DOMAIN_LABEL_REGEX from using

      (?:) to (?>)
      

      as follows.

      DOMAIN_LABEL_REGEX = "\\p{Alnum}(?>[\\p{Alnum}-]*\\p{Alnum})*"
      

      (All unit tests in DomainValidatorTest are succeed even if it changes as shown in the above-mentioned.)

        Activity

        Makoto Uchino created issue -
        Makoto Uchino made changes -
        Field Original Value New Value
        Attachment DomainValidator.java.diff [ 12370523 ]
        Ben Speakmon made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Ben Speakmon [ bens ]
        Sebb made changes -
        Description It seemed to take very long time to match the regular expression when long TLD (consists of around 30-characters over TLD) was specified for DomainValidator, this exponential performance will make it appear that the program has hung.

        The match time improves if it is possible to change DOMAIN_LABEL_REGEX from using (?:) to (?>), as follows.

        DOMAIN_LABEL_REGEX = "\\p{Alnum}(?>[\\p{Alnum}-]*\\p{Alnum})*"

        (All unit tests in DomainValidatorTest are succeed even if it changes as shown in the above-mentioned.)
        It seemed to take very long time to match the regular expression when long TLD (consists of around 30-characters over TLD) was specified for DomainValidator, this exponential performance will make it appear that the program has hung.

        The match time improves if it is possible to change DOMAIN_LABEL_REGEX from using
        {noformat}
        (?:) to (?>)
        {noformat}
        as follows.

        {noformat}
        DOMAIN_LABEL_REGEX = "\\p{Alnum}(?>[\\p{Alnum}-]*\\p{Alnum})*"
        {noformat}

        (All unit tests in DomainValidatorTest are succeed even if it changes as shown in the above-mentioned.)
        Sebb made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Ben Speakmon
            Reporter:
            Makoto Uchino
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development