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)