Bug 8261: prevent TestBundleDiag from throwing NPE 37/55737/8
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:03:53 +0000 (08:03 +0000)
commit667f362239f037fb01b670dbb20340ab2798ca1e
tree5ad07bbadc3967bcde71c272aa92aeb9a13a8e95
parent4f3ac386832f690815e74573b602314aa4b45e2e
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>
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