FELIX-4214 : Cache in BundleResources works only for a single metatype properties file per bundle
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1519468 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/BundleResources.java b/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/BundleResources.java
index 771d89a..5e1216d 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/BundleResources.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/l10n/BundleResources.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -112,10 +112,12 @@
locale = Locale.getDefault().toString();
}
+ final String key = basename + "-" + locale;
+
// check the cache, if the bundle has not changed
if ( isUpToDate() )
{
- Resources res = ( Resources ) resourcesByLocale.get( locale );
+ Resources res = ( Resources ) resourcesByLocale.get( key );
if ( res != null )
{
return res;
@@ -132,8 +134,9 @@
List resList = createResourceList( locale );
for ( Iterator ri = resList.iterator(); ri.hasNext(); )
{
- String tmpLocale = ( String ) ri.next();
- Resources res = ( Resources ) resourcesByLocale.get( tmpLocale );
+ final String tmpLocale = ( String ) ri.next();
+ final String tmpKey = basename + "-" + tmpLocale;
+ Resources res = ( Resources ) resourcesByLocale.get( tmpKey );
if ( res != null )
{
parentProperties = res.getResources();
@@ -142,13 +145,13 @@
{
Properties props = loadProperties( basename, tmpLocale, parentProperties );
res = new Resources( tmpLocale, props );
- resourcesByLocale.put( tmpLocale, res );
+ resourcesByLocale.put( tmpKey, res );
parentProperties = props;
}
}
// just return from the cache again
- return ( Resources ) resourcesByLocale.get( locale );
+ return ( Resources ) resourcesByLocale.get( key );
}