[MGNLMAIL-3] MgnlMailFactory fails with NPE when failing to initialise renderer Created: 26/Nov/12  Updated: 27/Nov/12  Resolved: 26/Nov/12

Status: Closed
Project: Magnolia Mail Module
Component/s: None
Affects Version/s: None
Fix Version/s: 5.0

Type: Bug Priority: Neutral
Reporter: Roman Kovařík Assignee: Roman Kovařík
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Cloners
clones MAGNOLIA-4673 MgnlMailFactory fails with NPE when f... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled

 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.



 Comments   
Comment by Roman Kovařík [ 26/Nov/12 ]

git commit:
https://git.magnolia-cms.com/gitweb/?p=modules/mail.git;a=commitdiff;h=58a6fb92bc8418c32a5251f5998784cd02846e5f

Generated at Mon Feb 12 06:02:40 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.