Bug 7423 - ResourceBundle lookup algorithm is not working as spec'd.
Summary: ResourceBundle lookup algorithm is not working as spec'd.
Status: CLOSED FIXED
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: unspecified
Hardware: All All
: P3 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 7424 7425 7426 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-03-25 03:59 UTC by Ryan Lubke
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
A more complete patch that handles the value attribute of fmt:locale being null or empty and allows the ResourceBundle lookup algorithm to work as spec'd. (2.43 KB, patch)
2002-03-25 18:10 UTC, Ryan Lubke
Details | Diff
Updated patches (2.13 KB, application/octet-stream)
2002-03-26 22:20 UTC, Ryan Lubke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Lubke 2002-03-25 03:59:54 UTC
After tracing through BundleSupport and LocaleSupport classes of
org/apache/taglibs/standard/tag/core/fmt, I discovered that the preferred
locales as provided by the Accept-Language request header were being ignored.

The problem is that the algorithm will check to see if the context init param,
or scoped attribute javax.servlet.jsp.jstl.fmt.locale was set before
interrogating the browser locales.  This is correct based on the spec, however,
the problem lies in LocaleSupport.parseLocale(String, String) - line 170.  If a
null value was returned, as it would be of javax.servlet.jsp.jstl.fmt.locale was
not set, parseLocale(String, String) will return the default locale of the
system where the container runs, and thus return a value when none should be
returned (See line 221 of BundleSupport).  Based on the spec (Section 8.3.2,
page 8-73), I would think that consideration of the containers default locale
would be illegal.

I changed the null check in LocalSupport.parseLocale(String, String) to return
null instead of the default locale (see diff below) and the algorithm began to
work as expected.  I haven't spent the time to see if the diff below has any
side effects, but I believe this is enough information to correct the issue.

*****************************************************************
Index: LocaleSupport.java
===================================================================
RCS file:
/home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/LocaleSupport.java,v
retrieving revision 1.14
diff -u -r1.14 LocaleSupport.java
--- LocaleSupport.java	23 Mar 2002 01:33:50 -0000	1.14
+++ LocaleSupport.java	25 Mar 2002 03:55:29 -0000
@@ -175,7 +175,8 @@
 	int index = -1;
 
 	if ((locale == null) || locale.equals("")) {
-
    return Locale.getDefault();
+
    //return Locale.getDefault();
+        return null;
 	}
 
 	if (((index = locale.indexOf(HYPHEN)) > -1)
*************************************************************
Comment 1 Ryan Lubke 2002-03-25 04:11:56 UTC
*** Bug 7424 has been marked as a duplicate of this bug. ***
Comment 2 Ryan Lubke 2002-03-25 04:12:24 UTC
*** Bug 7425 has been marked as a duplicate of this bug. ***
Comment 3 Ryan Lubke 2002-03-25 04:12:46 UTC
*** Bug 7426 has been marked as a duplicate of this bug. ***
Comment 4 Ryan Lubke 2002-03-25 15:25:43 UTC
Going back over the spec, I see why the containers default locale is used,
however, there is still the issue of this providing the default locale when it
shouldn't be.

Comment 5 Ryan Lubke 2002-03-25 18:10:15 UTC
Created attachment 1421 [details]
A more complete patch that handles the value attribute of fmt:locale being null or empty and allows the ResourceBundle lookup algorithm to work as spec'd.
Comment 6 Ryan Lubke 2002-03-26 22:20:01 UTC
Created attachment 1429 [details]
Updated patches