Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-4673

MgnlMailFactory fails with NPE when failing to initialise renderer.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Neutral
    • Resolution: Fixed
    • Affects Version/s: 4.5.4
    • Fix Version/s: 4.5.7
    • Component/s: mail
    • Labels:
      None
    • Magnolia Release:
      4.5.7

      Description

              if(renderers.containsKey(template.getType().toLowerCase())){
                  String rendererClass = renderers.get(template.getType().toLowerCase());
                  mail = Classes.quietNewInstance(rendererClass, template);
              }
              else {
                  mail = new SimpleEmail(template);
              }
      

      quietNewInstance() will return null in case of failure to instantiate renderer. This leads to NPE later down in the code when attempting to set properties on mail.

      I believe that failure to create renderer should not be swallowed but propagated up to calling code.
      Also code above should be able to handle situation when template type is not specified at all (And choose SimpleMail like in case of unrecognized renderer.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rkovarik Roman Kovařík
              Reporter:
              had Jan Haderka
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: