You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Scott.Wu (Jira)" <ji...@apache.org> on 2020/09/07 20:59:00 UTC
[jira] [Closed] (GROOVY-9724) Elvis operator covert double to null
in addiction
[ https://issues.apache.org/jira/browse/GROOVY-9724?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Scott.Wu closed GROOVY-9724.
----------------------------
Resolution: Invalid
This "issue" is related to println shorthand. Meanwhile, Elvis has much lower priority than "+" operator, so we need to apply bracket for the elvis expression.
Current logic is correct and the issue is not valid now.
> Elvis operator covert double to null in addiction
> -------------------------------------------------
>
> Key: GROOVY-9724
> URL: https://issues.apache.org/jira/browse/GROOVY-9724
> Project: Groovy
> Issue Type: Bug
> Components: GroovyScriptEngine
> Affects Versions: 2.4.19, 2.5.13
> Reporter: Scott.Wu
> Priority: Major
>
> Below statement will return error unexpected:
> {code:java}
> // code placeholder
> def vo = [INIT:0.00, PURCHASED:null]
> println (vo.INIT?:0.00) + (vo.PURCHASED?:0.00)
> {code}
> The error :
>
> Caught: java.lang.NullPointerException: Cannot execute null+0.00
> java.lang.NullPointerException: Cannot execute null+0.00
> at jdoodle.run(jdoodle.groovy:2)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> Note: Below expressions report errors as well:
>
> {code:java}
> // code placeholder
> println (vo.INIT?:0.00 + vo.PURCHASED?:0.00)
> println (vo.INIT?:0.00) + (vo.PURCHASED?:0.00)
> println vo.INIT?:0.00 + vo.PURCHASED?:0.00
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)