Apologies if I'm misinterpreting, but I think Antoni's concern is that the 
SimpleDateFormat's parse and format methods are not thread-safe. The creation 
of the converters and their registration can obviously be accomplished in a 
thread-safe manner, but if multiple threads call into parse and/or format at 
the same time, this will cause a problem. If that's not what Antoni was 
saying...it's still a problem ;-). Shouldn't you code a Converter's convert 
method with the same approach to thread-safety as an Action's execute/perform 
method? If your Converter maintains a SimpleDateFormat instance field that it 
uses to either format or parse, it's not thread safe.

Quoting Rick Reumann <[EMAIL PROTECTED]>:

> On Wednesday, November 6, 2002, 4:05:45 PM, Antoni wrote:
> 
> AR> Hi, I don't speak english very very well, so this is a bit
> AR> difficult for me to  explain, but I'll try ;-) ....
> 
>     No problem. Most American's don't speak English very well
>     (including myself I'm sure:)
> 
> AR> I have'nt looked at the beanutils Converter registration, do you have to
> 
> AR> register a class or an instance?
> 
>     It registers an instance one time in the static block at the top
>     of the action:
> 
> static {
>         DateBeanUtilsConverter dateConverter = new
> DateBeanUtilsConverter();
>         dateConverter.setFormatPattern( "MMddyyyy" );
>         StringBeanUtilsConverterDate myStringConverter = new
> StringBeanUtilsConverterDate();
>         myStringConverter.setFormatPattern( "MMddyyyy" );
>         ConvertUtils.register( dateConverter, java.util.Date.class );
>         ConvertUtils.register( myStringConverter, String.class ); 
>     }
>         
> AR> The problem here is that if there is only one instance of your class, and
> 
> AR> setFormatPattern is only called once, then if there are two request that
> 
> AR> require the use of your class a the same time, served by different
> threads, 
> AR> the parse method in your instance of SimpleDateFormat might be called 
> AR> concurrently, so (as it isn't thread save) it might fail.
> 
>     I'm not sure how this would happen as Eddie have both pointed out
>     that the static block will only get called one time regardless of
>     how many instances are created (at least on a single JVM I'm
>     pretty sure that's the case). (On top of that I'm pretty sure on
>     one JVM user's all share one servlet instance unless you maybe use
>     that SingleThreadModel which I think hands them out from a pool.
>     Moot point though I think if I do the stuff in the static block.
>     But I could be wrong).
> 
> -- 
> 
> Rick
> mailto:maillist@;reumann.net
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:struts-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@;jakarta.apache.org>
> 


-- 
Kris Schneider <mailto:kris@;dotech.com>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to