ICEfaces
  1. ICEfaces
  2. ICE-6217

Non-English locales lead to an exception when parsing dates

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Beta2
    • Fix Version/s: 2.0.0
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      ICEfaces 2

      Description

      In our class:

       icefaces/core/src/main/java/org/icefaces/impl/util/Util.java, to

      We set up a static DateFormat:

      public static final DateFormat HTTP_DATE = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");

      However, if the default is something other than English, a parsing exception can occur. The forum poster points to the relevant W3C spec:

      http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html

      and suggests making the following adjustment.

      public static final DateFormat HTTP_DATE = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);

        Issue Links

          Activity

          Deryk Sinotte created issue -
          Deryk Sinotte made changes -
          Field Original Value New Value
          Salesforce Case []
          Fix Version/s 2.0.0 [ 10230 ]
          Assignee Mircea Toma [ mircea.toma ]
          Deryk Sinotte made changes -
          Link This issue is duplicated by ICE-6186 [ ICE-6186 ]
          Deryk Sinotte made changes -
          Summary Non-English locales lead to an exception when parsing dates.I Non-English locales lead to an exception when parsing dates
          Salesforce Case []
          Hide
          Nicklas Karlsson added a comment -

          I tried adding the fix but now I get a

          10:28:31,192 WARNING [com.icesoft.faces.webapp.CompatResourceServlet] failed to parse date: ti, 09 marras 2010 09:51:29 EET: java.text.ParseException: Unparseable date: "ti, 09 marras 2010 09:51:29 EET"
          at java.text.DateFormat.parse(DateFormat.java:337) [:1.6.0_20]
          at com.icesoft.faces.webapp.CompatResourceServlet.service(CompatResourceServlet.java:61) [:]

          Strangely enough, before the fix the stuff it was trying to parse was in English.

          This is annoying since I sometimes have resources denied (broken icons etc for compat-components) which I suspect is tracked to this issue (even if the parsing exception appears to be caught and log-warn-handled)

          Show
          Nicklas Karlsson added a comment - I tried adding the fix but now I get a 10:28:31,192 WARNING [com.icesoft.faces.webapp.CompatResourceServlet] failed to parse date: ti, 09 marras 2010 09:51:29 EET: java.text.ParseException: Unparseable date: "ti, 09 marras 2010 09:51:29 EET" at java.text.DateFormat.parse(DateFormat.java:337) [:1.6.0_20] at com.icesoft.faces.webapp.CompatResourceServlet.service(CompatResourceServlet.java:61) [:] Strangely enough, before the fix the stuff it was trying to parse was in English. This is annoying since I sometimes have resources denied (broken icons etc for compat-components) which I suspect is tracked to this issue (even if the parsing exception appears to be caught and log-warn-handled)
          Hide
          Nicklas Karlsson added a comment -

          if I change my locale (with the applied fix) to en_US, I get a NFE for the blank string ""

          Show
          Nicklas Karlsson added a comment - if I change my locale (with the applied fix) to en_US, I get a NFE for the blank string ""
          Ken Fyten made changes -
          Salesforce Case []
          Assignee Priority P1
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #23148 Wed Nov 17 15:14:48 MST 2010 mircea.toma ICE-6217 Make sure English locale is used for parsing and formatting the HTTP dates.
          Files Changed
          Commit graph MODIFY /icefaces2/trunk/icefaces/core/src/main/java/org/icefaces/impl/util/Util.java
          Hide
          Mircea Toma added a comment - - edited

          Changed date formatter to always use English locale for parsing or formatting the HTTP dates.

          Show
          Mircea Toma added a comment - - edited Changed date formatter to always use English locale for parsing or formatting the HTTP dates.
          Mircea Toma made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          Mircea Toma added a comment - - edited

          To Nicklas Karlsson:

          I believe that the <<java.text.ParseException: Unparseable date: "ti, 09 marras 2010 09:51:29 EET">> exception is caused by a request for a resource that was loaded before the fix for the date formatter was applied. The second time the browser requests the resource it just echoes the date it received the first time the resource was loaded, but after the fix the date formatter cannot parse it anymore since a different system wide locale was used.

          Show
          Mircea Toma added a comment - - edited To Nicklas Karlsson: I believe that the <<java.text.ParseException: Unparseable date: "ti, 09 marras 2010 09:51:29 EET">> exception is caused by a request for a resource that was loaded before the fix for the date formatter was applied. The second time the browser requests the resource it just echoes the date it received the first time the resource was loaded, but after the fix the date formatter cannot parse it anymore since a different system wide locale was used.
          Ken Fyten made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Assignee Priority P1
          Hide
          Patrick Hayden added a comment -

          SimpleDateFormat is not thread safe so it should not be declared static and reused in a class unless access to the code is synchronized.

          Show
          Patrick Hayden added a comment - SimpleDateFormat is not thread safe so it should not be declared static and reused in a class unless access to the code is synchronized.

            People

            • Assignee:
              Mircea Toma
              Reporter:
              Deryk Sinotte
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: