Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5132

AlertValidator throws NotReadablePropertyException given null

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Affects Version/s: Platform 1.10.4, Platform 1.12.0, Platform 1.11.7, Platform 2.0.0, Core 2.1.0
    • Fix Version/s: Core 2.4.0
    • Component/s: None
    • Complexity:
      Low

      Description

      The AlertValidator.validate method throws NotReadablePropertyException when null is passed as the object to validate.

      Check by adding this test to the AlertValidatorTest

      	
      @Test(expected = org.springframework.beans.NotReadablePropertyException.class)
      public void iThinkThisIsABug() {
      		
        validator.validate(null, errors);
      }
      

      reason is use of rejectValue instead of the usual reject

      errors.rejectValue("alert","error.general");
      

      A solution is to use reject as this

      		if (alert == null) {
      			errors.reject("error.general");
      		}
      

      we do this in a bunch of validators. However the EncounterValidator does this

      		if (obj == null || !(obj instanceof Encounter)) {
      			throw new IllegalArgumentException("The parameter obj should not be null and must be of type " + Encounter.class);
      		}
      

      not sure which one we want to use. We should be consistent!

        Gliffy Diagrams

          Attachments

            Activity

              People

              Assignee:
              wandji69 Wandji Collins
              Reporter:
              teleivo Ivo Ulrich
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: