[MGNLDAM-723] Null-unsafe templating function: getAssetMap Created: 19/Sep/17 Updated: 16/Jun/21 Resolved: 16/Jun/21 |
|
| Status: | Closed |
| Project: | Magnolia DAM Module |
| Component/s: | DAM Templating |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Federico Navarro | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
MariaDB, CentOS |
||
| Issue Links: |
|
||||
| Template: |
|
||||
| Acceptance criteria: |
Empty
|
||||
| Task DoD: |
[X]*
Doc/release notes changes? Comment present?
[X]*
Downstream builds green?
[X]*
Solution information and context easily available?
[X]*
Tests
[X]*
FixVersion filled and not yet released
[X] 
Architecture Decision Record (ADR)
|
||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||
| Date of First Response: | |||||
| Visible to: |
, Marcel Evers, Mariusz Chruscielewski, Nuno Cruz, Simon Lutz, Stef te Winkel
|
||||
| Description |
|
This ticket is related to the Dam Templating Functions. First thing we've noticed is that the method below is not null-safe, so when an asset does not exist, it will throw a NullPointerException which will break the rendering process. Map<String, Object> getAssetMap(Asset asset) And consequently, this other method is also unsafe, as it calls the aforementioned one: Map<String, Object> getAssetMap(String itemKey) This can be avoided by using the following method instead: Map<String, Object> getAssetMapForAssetId(String assetKey) , as long as the asset is referred by its id. This leads also to the misleading documentation, as it is stated in https://documentation.magnolia-cms.com/display/DOCS/damfn that
, which is not completely true, as getAssetMapForAssetId is null-safe, while getAssetMap is not. |
| Comments |
| Comment by Jan Haderka [ 16/Jun/21 ] |
|
Updated documentation to mention need for null checking |