[jira] [Resolved] (GROOVY-8200) Shorthand |= results in NPE

2017-09-24 Thread Paul King (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-8200?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King resolved GROOVY-8200.
---
   Resolution: Fixed
Fix Version/s: 2.5.0-beta-2

I agree with Jochen's comment that we don't want any special treatment of the 
expansion into the {{or}} method in this case for the {{|=}} shorthand. I also 
agree with John's assessment in the PR that the implementation of {{or}} could 
handle this case for {{Boolean}} only. Proposed PR merged but only from 
2.5.0-beta-2 onwards which allows us some time to re-consider before 2.5.0 
final comes out.

> Shorthand |= results in NPE
> ---
>
> Key: GROOVY-8200
> URL: https://issues.apache.org/jira/browse/GROOVY-8200
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.11
> Environment: Groovy Version: 2.3.11 JVM: 1.7.0_80 Vendor: Oracle 
> Corporation OS: Linux
> java version "1.7.0_80"
> Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
> Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
>Reporter: Daniel Hammer
>Assignee: Paul King
> Fix For: 2.5.0-beta-2
>
> Attachments: shorthand_and.groovy, shorthand_or_symptom.groovy, 
> shorthand_xor_symptom.groovy
>
>
> I've stumbled across some curious behaviour for the shorthand assignment 
> operator in Groovy v2.3.11 (symptom also present in Groovy v2.4.9).
> The following [boolean or logic|^shorthand_or_symptom.groovy], unexpectedly 
> throws {{NullPointerException}}.
> {code}boolean x = null
> // short hand unrolled:  x = null || x
> x |= null // -> unexpected NullPointerException
> assert !x{code}
> The same approach for [boolean and logic|^shorthand_and.groovy], performs as 
> expected.
> {code}boolean x = null
> // short hand unrolled:  x = null && x
> x &= null
> assert !x{code}
> It's possible to work around the issue with explicit cast.
> {code}x |= null as boolean{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Resolved] (GROOVY-8200) Shorthand |= results in NPE

2017-05-23 Thread Jochen Theodorou (JIRA)

 [ 
https://issues.apache.org/jira/browse/GROOVY-8200?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Theodorou resolved GROOVY-8200.
--
Resolution: Not A Bug
  Assignee: Jochen Theodorou

x|=null is x=x|null, which results in x.or(null). You will see here that the 
expanded version and shorthand work the same. x=x||null will first convert x to 
boolean and depending on true or false we will also convert the null. Similar 
for the logic and binary and.


> Shorthand |= results in NPE
> ---
>
> Key: GROOVY-8200
> URL: https://issues.apache.org/jira/browse/GROOVY-8200
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.3.11
> Environment: Groovy Version: 2.3.11 JVM: 1.7.0_80 Vendor: Oracle 
> Corporation OS: Linux
> java version "1.7.0_80"
> Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
> Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
>Reporter: Daniel Hammer
>Assignee: Jochen Theodorou
> Attachments: shorthand_and.groovy, shorthand_or_symptom.groovy
>
>
> I've stumbled across some curious behaviour for the shorthand assignment 
> operator in Groovy v2.3.11 (symptom also present in Groovy v2.4.9).
> The following [boolean or logic|^shorthand_or_symptom.groovy], unexpectedly 
> throws {{NullPointerException}}.
> {code}boolean x = null
> // short hand unrolled:  x = null || x
> x |= null // -> unexpected NullPointerException
> assert !x{code}
> The same approach for [boolean and logic|^shorthand_and.groovy], performs as 
> expected.
> {code}boolean x = null
> // short hand unrolled:  x = null && x
> x &= null
> assert !x{code}
> It's possible to work around the issue with explicit cast.
> {code}x |= null as boolean{code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)