Change in ovirt-engine[master]: core: fixed gotcha in jdk8 streams

tjelinek at redhat.com tjelinek at redhat.com
Thu Apr 28 10:47:15 UTC 2016


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.
     *
     * <p>This is a <a
href="package-summary.html#StreamOps">short-circuiting
     * terminal operation</a>.
     *
     * @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 <mmucha at redhat.com>
---
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/NetworkConfigurator.java
A backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/NetworkConfiguratorTest.java
2 files changed, 60 insertions(+), 7 deletions(-)

Approvals:
  Martin Mucha: Verified
  Jenkins CI: Passed CI tests
  Allon Mureinik: Looks good to me, approved
  Yevgeny Zaspitsky: Looks good to me, but someone else must approve



-- 
To view, visit https://gerrit.ovirt.org/56646
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie15941484acb6eb0420bc55d72d5cbd9f3b5b1b2
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Mucha <mmucha at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Marcin Mirecki <mmirecki at redhat.com>
Gerrit-Reviewer: Martin Mucha <mmucha at redhat.com>
Gerrit-Reviewer: Tomas Jelinek <tjelinek at redhat.com>
Gerrit-Reviewer: Yevgeny Zaspitsky <yzaspits at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>



More information about the Engine-commits mailing list