FELIX-2860 Prevent NPE if no *.properties entries providing localization can be found in the bundle
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1074087 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/metatype/src/main/java/org/apache/felix/metatype/DefaultMetaTypeProvider.java b/metatype/src/main/java/org/apache/felix/metatype/DefaultMetaTypeProvider.java
index 6b8bb0d..4bf3855 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/DefaultMetaTypeProvider.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/DefaultMetaTypeProvider.java
@@ -124,21 +124,25 @@
pattern = localePrefix.substring( lastSlash + 1 );
}
- Enumeration entries = getBundle().findEntries( path, pattern + "*.properties", false );
TreeSet localeSet = new TreeSet();
- while ( entries.hasMoreElements() )
+
+ Enumeration entries = getBundle().findEntries( path, pattern + "*.properties", false );
+ if ( entries != null )
{
- URL url = ( URL ) entries.nextElement();
- String name = url.getPath();
- name = name.substring( name.lastIndexOf( '/' ) + 1 + pattern.length(), name.length()
- - ".properties".length() );
- if ( name.startsWith( "_" ) )
+ while ( entries.hasMoreElements() )
{
- name = name.substring( 1 );
- }
- if ( name.length() > 0 )
- {
- localeSet.add( name );
+ URL url = ( URL ) entries.nextElement();
+ String name = url.getPath();
+ name = name.substring( name.lastIndexOf( '/' ) + 1 + pattern.length(), name.length()
+ - ".properties".length() );
+ if ( name.startsWith( "_" ) )
+ {
+ name = name.substring( 1 );
+ }
+ if ( name.length() > 0 )
+ {
+ localeSet.add( name );
+ }
}
}