You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by bu...@apache.org on 2006/04/04 04:33:20 UTC

DO NOT REPLY [Bug 39195] New: - getRequestLocale could throw exception on JBOSS

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39195>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39195

           Summary: getRequestLocale could throw exception on JBOSS
           Product: Taglibs
           Version: nightly
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: PatchAvailable
          Severity: normal
          Priority: P2
         Component: Standard Taglib
        AssignedTo: taglibs-dev@jakarta.apache.org
        ReportedBy: zb@bisp.com


When I use standard taglibs in jsp to setResourceBundle I get an
exception on JBOSS(it's good on jetspeed2). I found this is because
getRequestLocale in Util.java use  request.getHeaders("accept-language")  to get
a values(Enumeration), and expected this values to be not null.
But servlet api said "If the container does not allow access to header
information, return null". I guess this is the case in JBOSS. So I add a check
for values and return request.getLocales() when values is null, the problem
resolved. The following is the patch:


*** standard/src/org/apache/taglibs/standard/tag/common/core/Util.java
2006-04-02 16:12:11.000000000 +0800
--- Util.java.new	2006-04-03 12:11:59.000000000 +0800
***************
*** 278,283 ****
--- 278,286 ----
       */
      public static Enumeration getRequestLocales(HttpServletRequest request) {
       
          Enumeration values = request.getHeaders("accept-language");
+ 		if(values == null){
+ 			return request.getLocales();
+ 		}
          if (values.hasMoreElements()) {
              // At least one "accept-language". Simply return
              // the enumeration returned by request.getLocales().

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 39195] - getRequestLocale could throw exception on JBOSS

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39195>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39195





------- Additional Comments From bayard@apache.org  2006-12-27 14:10 -------

The javadoc says:

"a String containing the value of the requested header, or null  if the request
does not have a header of that name"

http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/HttpServletRequest.html#getHeader(java.lang.String)

So null protecting here seems fine. I'm not sure that the fix below makes sense
though - reading the source it looks more likely that an empty enumeration
should be returned and not request.getLocales().

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 39195] - getRequestLocale could throw exception on JBOSS

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39195>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39195


bayard@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From bayard@apache.org  2007-03-27 12:22 -------
I'm fixing this by returning a new empty enumeration when there's a null
accept-language header:

Index: src/org/apache/taglibs/standard/tag/common/core/Util.java
===================================================================
--- src/org/apache/taglibs/standard/tag/common/core/Util.java   (revision 523035)
+++ src/org/apache/taglibs/standard/tag/common/core/Util.java   (working copy)
@@ -278,6 +278,12 @@
      */
     public static Enumeration getRequestLocales(HttpServletRequest request) { 
      
         Enumeration values = request.getHeaders("accept-language");
+        if (values == null) {
+            // No header for "accept-language". Simply return
+            // a new empty enumeration.
+            // System.out.println("Null accept-language");
+            return new Vector().elements();
+        } else
         if (values.hasMoreElements()) {
             // At least one "accept-language". Simply return
             // the enumeration returned by request.getLocales(). 




svn ci -m "Fixing the issue raised in 39195. It's legal for a null request
header to come back.
 " src/org/apache/taglibs/standard/tag/common/core/Util.java 
Sending        src/org/apache/taglibs/standard/tag/common/core/Util.java
Transmitting file data .
Committed revision 523043.

svn ci -m "Adding missing import for Vector"
src/org/apache/taglibs/standard/tag/common/core/Ut
il.java 
Sending        src/org/apache/taglibs/standard/tag/common/core/Util.java
Transmitting file data .
Committed revision 523045.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


DO NOT REPLY [Bug 39195] - getRequestLocale could throw exception on JBOSS

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39195>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39195





------- Additional Comments From zb@bisp.com  2006-04-04 03:35 -------
Created an attachment (id=18023)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=18023&action=view)
patch to Util.java getRequestLocale


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org