[MAGNOLIA-3195] I18nContentWrapper may also wrap null nodes Created: 09/May/10  Updated: 23/Jan/13  Resolved: 09/May/10

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 4.3.1
Fix Version/s: 4.3.2

Type: Bug Priority: Major
Reporter: Fabrizio Giustina Assignee: Fabrizio Giustina
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

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   

When using I18nContentSupport the NodeMapWrapper may incorrectly wrap also null values, causing NPEs when trying to access properties.

This is a sample code (it surely happens using the now deprecated getChildByName() method, but there could be other cases):

Content test = wrapped.getChildByName("child")
if (test !=null) {
  test.getNodeData("x");
} 

Without the content wrapper If getChildByName("child") return nulls everything works fine.
But If the original node is wrapped, the returned null gets wrapped in a I18nContentWrapper, so that the null check passes but the getNodeData() call will throw a NPE.



 Comments   
Comment by Fabrizio Giustina [ 09/May/10 ]

added a null check in I18nContentWrapper.wrap() to avoid any possible mistake

Generated at Mon Feb 12 03:44:07 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.