Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.11
-
None
-
None
-
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)
Description
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, unexpectedly throws NullPointerException.
boolean x = null // short hand unrolled: x = null || x x |= null // -> unexpected NullPointerException assert !x
The same approach for boolean and logic, performs as expected.
boolean x = null // short hand unrolled: x = null && x x &= null assert !x
It's possible to work around the issue with explicit cast.
x |= null as boolean
Attachments
Attachments
Issue Links
- links to