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

Calling User.addName throws a NullPointerException if the user isn't attached to a Person yet

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Non-Essential
    • Resolution: Fixed
    • Affects Version/s: OpenMRS 1.6.0, OpenMRS 1.6.1, OpenMRS 1.6.2, OpenMRS 1.7.0, OpenMRS 1.8.0
    • Fix Version/s: OpenMRS 1.9.0
    • Component/s: None
    • Labels:
      None
    • Complexity:
      Low

      Description

      The Request Account module doesn't work on OpenMRS (since 1.6 I guess) because the following code (which would have been fine before 1.6) no longer works:

      User u = new User();
      u.addName(new PersonName(request.getGivenName(), null, request.getFamilyName()));
      

      In this particular case I'm going to just change the Request Account module to require OpenMRS 1.6, but I'm also going to commit a fix so that any User set/add methods that call getPerson() will create a new Person if it's currently null. (Get methods will continue to return null.)

      The exception is

      java.lang.NullPointerException 
      org.openmrs.User.addName(User.java:463)
      org.openmrs.module.requestaccount.impl.RequestAccountServiceImpl.createUser(RequestAccountServiceImpl.java:60)
      org.openmrs.module.requestaccount.impl.RequestAccountServiceImpl.approveAccount(RequestAccountServiceImpl.java:48)
      ...
      

        Attachments

          Activity

            People

            Assignee:
            darius Darius Jazayeri [X] (Inactive)
            Reporter:
            darius Darius Jazayeri [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: