Tapestry
  1. Tapestry
  2. TAPESTRY-2253

A brain dead implementation of toString() on a custom data object can cause the Required validator to throw a NullPointerExcepton

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 5.0.12
    • Fix Version/s: 5.0.12
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      the validate method of the Required validator contains following code line:

      if (value == null || value.toString().equals(""))...

      if the toString method returns null an exception will occur (happened to me accidentally )

      this code line should at least be changed to:

      if (value == null || "".equals(value.toString())... to prevent NPE

        Activity

        Hide
        Kevin Menard added a comment -

        I'd make the change to help users that shoot themselves in the foot, but under no circumstance should null be returned from toString(). It violates the general contract of the method.

        Show
        Kevin Menard added a comment - I'd make the change to help users that shoot themselves in the foot, but under no circumstance should null be returned from toString(). It violates the general contract of the method.

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Kristian Marinkovic
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development