[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: Re: error in svnClientAdapter command-line xml date parsing.

From: Deadman, Hal <Hal.Deadman_at_Tallan.com>
Date: 2005-01-06 18:23:57 CET

I haven't looked closely at the code, but is there any chance that two
threads would call the parse method at the same time on the same
instance of SDF (since it is static)? With Eclipse letting you
background operations, it seems like it could happen. It's tempting to
use a static SDF but I have seen exceptions in other applications if the
parse method is called twice on the same DateFormat instance at the same
time. It's fairly common in web applications since there are many
concurrent users.

http://www-106.ibm.com/developerworks/java/library/j-jtp09263.html
"As an example of this pitfall, the class java.text.SimpleDateFormat is
not thread-safe, but it wasn't until the 1.4 JDK that this was
documented in the Javadoc. How many developers mistakenly created a
static instance of SimpleDateFormat and used it from multiple threads,
unaware that their programs were not going to behave correctly under
heavy load? Don't do this to your customers or colleagues!"

Granted, there is no heavy load going on, and it may be extremely
unlikely that it would happen, and it looks like any parse exception is
getting eaten by the code anyway, but for some reason I feel compelled
to comment....

> -----Original Message-----
> From: Mark Phippard [mailto:MarkP@softlanding.com]
> Sent: Thursday, January 06, 2005 11:32 AM
> To: dev@subclipse.tigris.org
> Subject: Re: error in svnClientAdapter command-line xml date parsing.
>
> It seems like we could just add this then for a patch. It initializes
the
> TimeZone in the xmlFormat formatter when it is constructed.
>
>
> Index:
>
C:/workspaces/subclipse/svnClientAdapter/src/main/org/tigris/subversion/
sv
> nclientadapter/commandline/Helper.java
> ===================================================================
> ---
>
C:/workspaces/subclipse/svnClientAdapter/src/main/org/tigris/subversion/
sv
> nclientadapter/commandline/Helper.java
> (revision 1186)
> +++
>
C:/workspaces/subclipse/svnClientAdapter/src/main/org/tigris/subversion/
sv
> nclientadapter/commandline/Helper.java
> (working copy)
> @@ -37,6 +37,10 @@
> // 2003-10-13T12:54:42.957948Z
> private static DateFormat xmlFormat =
> new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
> + // Initialize timezone to GMT for xmlFormat
> + static {
> +
xmlFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
> + }
>
> /**
> * A non-instantiable class
>
>
________________________________________________________________________
__
> ___
> Scanned for SoftLanding Systems, Inc. by IBM Email Security Management
> Services powered by MessageLabs.
>
________________________________________________________________________
__
> ___
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subclipse.tigris.org
> For additional commands, e-mail: dev-help@subclipse.tigris.org
>
Received on Fri Jan 7 04:23:57 2005

This is an archived mail posted to the Subclipse Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.