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

        Kristian Marinkovic created issue -
        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.
        Kevin Menard made changes -
        Field Original Value New Value
        Assignee Kevin Menard [ nirvdrum ]
        Howard M. Lewis Ship made changes -
        Assignee Kevin Menard [ nirvdrum ] Howard M. Lewis Ship [ hlship ]
        Priority Major [ 3 ] Trivial [ 5 ]
        Howard M. Lewis Ship made changes -
        Summary Required Validator can produce NullPointerExceptions A brain dead implementation of toString() on a custom data object can cause the Required validator to throw a NullPointerExcepton
        Howard M. Lewis Ship made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 5.0.12 [ 12313048 ]
        Resolution Fixed [ 1 ]
        Mark Thomas made changes -
        Workflow jira [ 12425890 ] Default workflow, editable Closed status [ 12568660 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12568660 ] jira [ 12591691 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        34d 5h 52m 1 Howard M. Lewis Ship 15/Apr/08 22:42

          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