FELIX-4401 avoid NPE fetching a nonexistant DTO
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1602638 13f79535-47bb-0310-9956-ffa450edef68
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 163d525..62c2b86 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
@@ -2,6 +2,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -56,14 +57,24 @@
return result;
}
- public ComponentDescriptionDTO getComponentDescriptionDTO(Bundle bundle,
- String name) {
+ public ComponentDescriptionDTO getComponentDescriptionDTO(Bundle bundle, String name) {
ComponentHolder<?> holder = componentRegistry.getComponentHolder(bundle, name);
- return holderToDescription(holder);
+ if ( holder != null )
+ {
+ return holderToDescription(holder);
+ }
+ else
+ {
+ return null;
+ }
}
public Collection<ComponentConfigurationDTO> getComponentConfigurationDTOs(
ComponentDescriptionDTO description) {
+ if ( description == null)
+ {
+ return Collections.emptyList();
+ }
ComponentHolder<?> holder = getHolderFromDescription( description);
//Get a fully filled out valid description DTO
description = holderToDescription(holder);
@@ -130,7 +141,7 @@
return dto;
}
- private ComponentHolder getHolderFromDescription(
+ private ComponentHolder<?> getHolderFromDescription(
ComponentDescriptionDTO description) {
if (description.bundle == null)
{