From tjelinek at redhat.com Thu Apr 28 06:47:16 2016 Content-Type: multipart/mixed; boundary="===============2006167903333103883==" MIME-Version: 1.0 From: tjelinek at redhat.com To: engine-commits at ovirt.org Subject: Change in ovirt-engine[master]: core: fixed gotcha in jdk8 streams Date: Thu, 28 Apr 2016 06:47:15 -0400 Message-ID: <201604281047.u3SAlF0j014634@gerrit.ovirt.org> In-Reply-To: gerrit.1461689333287.Ie15941484acb6eb0420bc55d72d5cbd9f3b5b1b2@gerrit.ovirt.org --===============2006167903333103883== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Tomas Jelinek has submitted this change and it was merged. Change subject: core: fixed gotcha in jdk8 streams ...................................................................... core: fixed gotcha in jdk8 streams code .findFirst().orElse(null) does NOT return first instance in stream or null. It returns first instance, if there's non-null first instance. It returns null if stream is empty. And throws NPE, when there's null valued instance in stream. Javadoc: /** * Returns an {@link Optional} describing the first element of this stream, * or an empty {@code Optional} if the stream is empty. If the stream has * no encounter order, then any element may be returned. * *
This is a short-circuiting
* terminal operation.
*
* @return an {@code Optional} describing the first element of
this stream,
* or an empty {@code Optional} if the stream is empty
* @throws NullPointerException if the element selected is null
*/
Change-Id: Ie15941484acb6eb0420bc55d72d5cbd9f3b5b1b2
Signed-off-by: Martin Mucha