You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Keith Wannamaker <Ke...@Wannamaker.org> on 2001/05/20 23:40:32 UTC
JDK DateFormat bug & workaround
There is a lingering bug in (at least) Sun's JDK
that causes SimpleDateFormat to occasionaly throw a
StringIndexOutOfBoundsException instead of a
ParseException.
<http://developer.java.sun.com/developer/bugParade/bugs/4212077.html>
(Requires a cookie; thanks, Sun)
Some rogue client out there is sending a malformed
HttpDate for the 'If-Modified-Since' header (don't
know which, that info was not logged) which triggers
this bug on our servers.
I propose to follow the advice in the Sun bug report
and catch this additional exception so that Tomcat
might recover gracefully:
--- RequestUtil.java 2001/05/11 22:34:28 1.14.2.4
+++ RequestUtil.java 2001/05/20 22:36:41
@@ -572,17 +572,20 @@
try {
date = rfc1123Format.parse(dateString);
} catch (ParseException e) { }
+ catch (StringIndexOutOfBoundsException e) { }
if( date==null)
try {
date = rfc1036Format.parse(dateString);
} catch (ParseException e) { }
+ catch (StringIndexOutOfBoundsException e) { }
if( date==null)
try {
date = asctimeFormat.parse(dateString);
} catch (ParseException pe) {
}
+ catch (StringIndexOutOfBoundsException e) { }
if(date==null) {
return -1;
Any objections to putting this in 3.2.2?
Keith
RE: JDK DateFormat bug & workaround
Posted by Marc Saegesser <ma...@apropos.com>.
Looks safe enough. Go ahead.
> -----Original Message-----
> From: Keith Wannamaker [mailto:Keith@Wannamaker.org]
> Sent: Sunday, May 20, 2001 4:41 PM
> To: Tomcat-Dev@Jakarta.Apache.Org
> Subject: JDK DateFormat bug & workaround
>
>
> There is a lingering bug in (at least) Sun's JDK
> that causes SimpleDateFormat to occasionaly throw a
> StringIndexOutOfBoundsException instead of a
> ParseException.
> <http://developer.java.sun.com/developer/bugParade/bugs/4212077.html>
> (Requires a cookie; thanks, Sun)
>
> Some rogue client out there is sending a malformed
> HttpDate for the 'If-Modified-Since' header (don't
> know which, that info was not logged) which triggers
> this bug on our servers.
>
> I propose to follow the advice in the Sun bug report
> and catch this additional exception so that Tomcat
> might recover gracefully:
>
> --- RequestUtil.java 2001/05/11 22:34:28 1.14.2.4
> +++ RequestUtil.java 2001/05/20 22:36:41
> @@ -572,17 +572,20 @@
> try {
> date = rfc1123Format.parse(dateString);
> } catch (ParseException e) { }
> + catch (StringIndexOutOfBoundsException e) { }
>
> if( date==null)
> try {
> date = rfc1036Format.parse(dateString);
> } catch (ParseException e) { }
> + catch (StringIndexOutOfBoundsException e) { }
>
> if( date==null)
> try {
> date = asctimeFormat.parse(dateString);
> } catch (ParseException pe) {
> }
> + catch (StringIndexOutOfBoundsException e) { }
>
> if(date==null) {
> return -1;
>
> Any objections to putting this in 3.2.2?
>
> Keith