Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
scr-1.2.0
-
None
Description
Lukas Kolisko reports in response to FELIX-1827:
If a service component does not provide any service and system security manager is set , then
AbstractComponentManager.java line 537
final String[] services = getComponentMetadata().getServiceMetadata().getProvides(); fails with NPE because ServiceMetadata is null.
Possible patch:
Index: src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
===================================================================
— src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java (revision 888421)
+++ src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java (working copy)
@@ -33,6 +33,7 @@
import org.apache.felix.scr.impl.ComponentActivatorTask;
import org.apache.felix.scr.impl.metadata.ComponentMetadata;
import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
+import org.apache.felix.scr.impl.metadata.ServiceMetadata;
import org.osgi.framework.Bundle;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServicePermission;
@@ -534,18 +535,22 @@
boolean allowed = true;
if ( System.getSecurityManager() != null )
{
- final String[] services = getComponentMetadata().getServiceMetadata().getProvides();
- if ( services != null && services.length > 0 )
+ final ServiceMetadata metadata = getComponentMetadata().getServiceMetadata();
+ if ( metadata != null )
{ - final Bundle bundle = getBundle();
- for ( int i = 0; i < services.length; i++ )
+ final String[] services = metadata.getProvides();
+ if ( services != null && services.length > 0 )
{ - final Permission perm = new ServicePermission( services[i], ServicePermission.REGISTER );
- if ( !bundle.hasPermission( perm ) )
+ final Bundle bundle = getBundle();
+ for ( int i = 0; i < services.length; i++ )
{ - log( LogService.LOG_INFO, "Permission to register service
{0} is denied", new Object[]
- { services[i] }, null );
- allowed = false;
+ final Permission perm = new ServicePermission( services[i], ServicePermission.REGISTER );
+ if ( !bundle.hasPermission( perm ) )
+ {
+ log( LogService.LOG_INFO, "Permission to register service {0}is denied", new Object[]
{ services[i] }
+, null );
+ allowed = false;
+ }
}
}
}