This is an automated email from the ASF dual-hosted git repository.
tjwatson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new 8815594fba [FELIX-6564] Fixed NPE while retrieving component
descriptions from SCR
new a27dd47244 Merge pull request #172 from amitjoy/fix/npe/scr
8815594fba is described below
commit 8815594fba7c7aeb121ae0cff33c67f36f486d36
Author: Amit Kumar Mondal <[email protected]>
AuthorDate: Wed Sep 14 13:20:56 2022 +0200
[FELIX-6564] Fixed NPE while retrieving component descriptions from SCR
Fixes https://issues.apache.org/jira/browse/FELIX-6564
---
.../scr/impl/runtime/ServiceComponentRuntimeImpl.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git
a/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
b/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
index 0f13941502..32573091e0 100644
---
a/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
+++
b/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
@@ -117,6 +117,10 @@ public class ServiceComponentRuntimeImpl implements
ServiceComponentRuntime
try
{
ComponentHolder<?> holder = getHolderFromDescription( description);
+ // the holder can also be null if the associated component is
deregistered
+ if (holder == null) {
+ return Collections.emptyList();
+ }
// Get a fully filled out valid description DTO
description = holderToDescription(holder);
if ( description == null)
@@ -146,6 +150,9 @@ public class ServiceComponentRuntimeImpl implements
ServiceComponentRuntime
try
{
ComponentHolder<?> holder = getHolderFromDescription( description);
+ if (holder == null) {
+ return false;
+ }
return holder.isEnabled();
}
catch ( IllegalStateException ise)
@@ -163,6 +170,9 @@ public class ServiceComponentRuntimeImpl implements
ServiceComponentRuntime
try
{
final ComponentHolder<?> holder = getHolderFromDescription(
description);
+ if (holder == null) {
+ throw new IllegalStateException("The component is not
available in the runtime");
+ }
final boolean doUpdate = !holder.isEnabled();
final Promise<Void> result = holder.enableComponents(true);
if ( doUpdate ) {
@@ -185,6 +195,9 @@ public class ServiceComponentRuntimeImpl implements
ServiceComponentRuntime
try
{
final ComponentHolder<?> holder = getHolderFromDescription(
description);
+ if (holder == null) {
+ throw new IllegalStateException("The component is not
available in the runtime");
+ }
final boolean doUpdate = holder.isEnabled();
final Promise<Void> result = holder.disableComponents(true);
//synchronous
if ( doUpdate ) {
@@ -294,6 +307,10 @@ public class ServiceComponentRuntimeImpl implements
ServiceComponentRuntime
}
long bundleId = description.bundle.id;
Bundle b = context.getBundle(bundleId);
+ if (b == null) {
+ // the bundle is possibly uninstalled
+ return null;
+ }
String name = description.name;
return componentRegistry.getComponentHolder(b, name);
}