incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1138316 - in /sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n: LocaleResolver.java impl/I18NFilter.java
Date Wed, 22 Jun 2011 06:36:50 GMT
Author: fmeschbe
Date: Wed Jun 22 06:36:49 2011
New Revision: 1138316

URL: http://svn.apache.org/viewvc?rev=1138316&view=rev
Log:
SLING-2107 Check the LocaleResolve.resolveLocale result in the getLocaleList and ensure a
singleton list with the default locale is returne din case the LocaleResolver returns null
(for stability only, spec says list must not be null) or an empty list

Modified:
    sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/LocaleResolver.java
    sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java

Modified: sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/LocaleResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/LocaleResolver.java?rev=1138316&r1=1138315&r2=1138316&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/LocaleResolver.java
(original)
+++ sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/LocaleResolver.java
Wed Jun 22 06:36:49 2011
@@ -41,6 +41,9 @@ public interface LocaleResolver {
      * request. The list returned is assumed to be ordered by preference where
      * the first entry is the prefered <code>Locale</code> and the last entry
is
      * the least prefered <code>Locale</code>.
+     * <p>
+     * Returning an empty list is equivalent to returning a singleton list whose
+     * single entry is the {@link ResourceBundleProvider#getDefaultLocale()}.
      *
      * @param request The <code>SlingHttpServletRequest</code> providing hints
      *            and information for the <code>Locale</code> resolution.

Modified: sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java?rev=1138316&r1=1138315&r2=1138316&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
(original)
+++ sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
Wed Jun 22 06:36:49 2011
@@ -154,12 +154,7 @@ public class I18NFilter implements Filte
         @Override
         public Locale getLocale() {
             if (locale == null) {
-                List<Locale> localeList = getLocaleList();
-                if (localeList.isEmpty()) {
-                    locale = bundleProvider.getDefaultLocale();
-                } else {
-                    locale = localeList.get(0);
-                }
+                locale = this.getLocaleList().get(0);
             }
 
             return locale;
@@ -172,7 +167,10 @@ public class I18NFilter implements Filte
 
         private List<Locale> getLocaleList() {
             if (localeList == null) {
-                localeList = localeResolver.resolveLocale(this.getSlingRequest());
+                List<Locale> resolved = localeResolver.resolveLocale(this.getSlingRequest());
+                this.localeList = (resolved != null && !resolved.isEmpty())
+                        ? resolved
+                        : Collections.singletonList(this.bundleProvider.getDefaultLocale());
             }
 
             return localeList;



Mime
View raw message