Bug 8261: prevent TestBundleDiag from throwing NPE 48/55748/2
authorRyan Goulding <ryandgoulding@gmail.com>
Thu, 20 Apr 2017 13:44:00 +0000 (09:44 -0400)
committerStephen Kitt <skitt@redhat.com>
Fri, 21 Apr 2017 08:04:23 +0000 (08:04 +0000)
commitb904c604ddb8977254177fdbc01b1688f489fdc2
tree80fa45d2b969c1a02306722658e8c81c7ad1aa8b
parent6fa477ce1d221c671e927df41b67bc5abff9b831
Bug 8261: prevent TestBundleDiag from throwing NPE

There is a stack trace demonstrating this behavior in bug 8261.  In
short, TestBundleDiag is occasionally throwing NPE because a null
Bundle is returned from serviceReference.getBundle().  This change just
adds some null sanity checking in TestBundleDiag and
ServiceReferenceUtil.

Also, in ServiceReferenceUtil, a local variable is extracted just in
case the object is mutated between calls.  This at least gives a
consistent snapshot for usingBundles over the course of the method
call.

Change-Id: I334b0850be4a2045f9eeb260f5de4af542896dc1
Signed-off-by: Ryan Goulding <ryandgoulding@gmail.com>
(cherry picked from commit 667f362239f037fb01b670dbb20340ab2798ca1e)
bundles-test/src/main/java/org/opendaylight/odlparent/bundlestest/ServiceReferenceUtil.java
bundles-test/src/main/java/org/opendaylight/odlparent/bundlestest/TestBundleDiag.java
bundles-test/src/test/java/org/opendaylight/odlparent/bundlestest/ServiceReferenceUtilTest.java
bundles4-test/src/main/java/org/opendaylight/odlparent/bundles4test/ServiceReferenceUtil.java
bundles4-test/src/main/java/org/opendaylight/odlparent/bundles4test/TestBundleDiag.java
bundles4-test/src/test/java/org/opendaylight/odlparent/bundles4test/ServiceReferenceUtilTest.java