Skip to content

Commit

Permalink
[BundleContextExtension] More informative error on null BundleContext
Browse files Browse the repository at this point in the history
Fixes osgi#302.

Signed-off-by: Fr Jeremy Krieg <fr.jkrieg@greekwelfaresa.org.au>
  • Loading branch information
kriegfrj committed Mar 28, 2022
1 parent b5f1603 commit dec6328
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ static Store getStore(ExtensionContext extensionContext) {
@Override
protected Object resolveValue(TargetType targetType, InjectBundleContext injection,
ExtensionContext extensionContext) throws ParameterResolutionException {
return getBundleContext(extensionContext);
BundleContext retval = getBundleContext(extensionContext);
if (retval == null) {
throw new ParameterResolutionException(
"Bundle context was null. Check that you are running your test in an OSGi framework.");
}
return retval;
}
}

0 comments on commit dec6328

Please sign in to comment.