You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Radu Cotescu (Jira)" <ji...@apache.org> on 2020/08/25 16:31:00 UTC

[jira] [Commented] (SLING-9314) NPE in ObjectModel.toBoolean(Object) when object.toString() returns null

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

Radu Cotescu commented on SLING-9314:
-------------------------------------

[~paul.bjorkstrand], if I don't see any objections for https://github.com/apache/sling-org-apache-sling-scripting-sightly-runtime/pull/6 until tomorrow I will merge the change to {{master}}.

> NPE 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
>             Fix For: Scripting HTL Runtime 1.2.4-1.4.0
>
>
> 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)