[ 
https://issues.apache.org/jira/browse/SLING-9314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17184092#comment-17184092
 ] 

Radu Cotescu edited comment on SLING-9314 at 8/25/20, 2:19 PM:
---------------------------------------------------------------

If the object in question returns a {{null}} for {{#toString}}, then the 
processing will continue and check if the object is of other types. Just the 
fact that the object's {{#toString}} method returns {{null}} doesn't mean that 
the result of {{ObjectModel.toBoolean(Object)}} will be {{false}}. If you agree 
to this, then the fix is trivial.


was (Author: radu.cotescu):
If the object in question returns a {{null}} for {{#toString}}, then the 
processing will continue and check if the object is of other types. Just the 
fact that the object's {{#toString}} method returns {{null}}} doesn't mean that 
the result of {{ObjectModel.toBoolean(Object)}} will be {{false}}. If you agree 
to this, then the fix is trivial.

> HTL null pointer in ObjectModel.toBoolean(Object) when object.toString() 
> returns null
> -------------------------------------------------------------------------------------
>
>                 Key: SLING-9314
>                 URL: https://issues.apache.org/jira/browse/SLING-9314
>             Project: Sling
>          Issue Type: Bug
>          Components: Scripting
>    Affects Versions: Scripting HTL Runtime 1.0.0-1.4.0, Scripting HTL Runtime 
> 1.1.0-1.4.0, Scripting HTL Runtime 1.1.2-1.4.0
>            Reporter: Paul Bjorkstrand
>            Assignee: Radu Cotescu
>            Priority: Major
>
> Though it is bad practice, it is possible that an object can return null from 
> its toString() method. ObjectModel.toBoolean(Object) \[[Line 
> 161|https://github.com/apache/sling-org-apache-sling-scripting-sightly-runtime/blob/master/src/main/java/org/apache/sling/scripting/sightly/render/ObjectModel.java#L161]\]
>  calls .trim() on a potentially null object.
> This causes a difficult to troubleshoot, deeply nested, and cryptic exception 
> to be raised. If object.toString() returns null, then it should be treated 
> the same as nearly the rest of HTL, where null is considered "falsey". Doing 
> so will save hours of difficult troubleshooting.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to