[MGNLDAM-509] DamTemplatingFunctions: getRendition(String, String) must do a null check on the inner asset Created: 03/Sep/14 Updated: 08/Sep/14 Resolved: 08/Sep/14 |
|
| Status: | Closed |
| Project: | Magnolia DAM Module |
| Component/s: | None |
| Affects Version/s: | 2.0.2 |
| Fix Version/s: | 2.0.3 |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Christian Ringele | Assignee: | Federico Grilli |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | support | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Template: |
|
||||
| Patch included: |
Yes
|
||||
| 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 |
|
In:
public AssetRendition getRendition(String itemKey, String renditionName) {
Asset asset = getAsset(itemKey);
return getRendition(asset, MediaType.parse(asset.getMimeType()), renditionName);
}
the asset mus be null checked, as later is called "MediaType.parse(asset.getMimeType())" on it. Like this a un-handled exception is thrown which is not really catch-able in the freemarker script (null pointer check doesn't work). Change to:
public AssetRendition getRendition(String itemKey, String renditionName) {
Asset asset = getAsset(itemKey);
if (asset == null) {
return null;
}
return getRendition(asset, MediaType.parse(asset.getMimeType()), renditionName);
}
Possible workaround:
|