[ 
http://jira.dspace.org/jira/browse/DS-594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11677#action_11677
 ] 

Robin Taylor commented on DS-594:
---------------------------------

Hi Andrew,

Rather than clone the variable passed as input parameter 'SimpleDateFormat 
sdf',  would it be an alternative to just make the various  SimpleDateFormat  
variables instance variables rather than static variables ?  

Cheers, Robin.

> DCDate parsing thread synchronization issue
> -------------------------------------------
>
>                 Key: DS-594
>                 URL: http://jira.dspace.org/jira/browse/DS-594
>             Project: DSpace 1.x
>          Issue Type: Bug
>          Components: DSpace API
>    Affects Versions: 1.6.1
>            Reporter: Andrew Taylor
>            Assignee: Robin Taylor
>            Priority: Minor
>             Fix For: 1.7.0
>
>         Attachments: DCDateConcurrencyTest.java, DS-594.diff
>
>
> I have been getting a variety of exceptions coming from 
> org.dspace.content.DCDate that look suspiciously like SimpleDateFormat thread 
> synchronization issues (such as "java.lang.NumberFormatException: multiple 
> points"). On closer inspection I noticed that the DCDate(String) constructor 
> is calling the 'tryParse' method which is not 'static' synchronized and thus 
> the locking is based on the DCDate instance itself and not the class. As such 
> the 'synchronized' keyword on tryParse is redundent since that method is only 
> called by the constructor (a time when no other code can get a lock on the 
> DCDate instance).
> The fix would be to either add the 'static' keyword to tryParse, which would 
> be a fairly major performance bottleneck, or to simply clone the 
> SimpleDateFormat instance and use that to parse the string. Example code:
>     private static Date tryParse(SimpleDateFormat sdf,  String source)
>     {
>         try
>         {
>             SimpleDateFormat clone = (SimpleDateFormat) sdf.clone();
>             return clone.parse(source);
>         }
>         catch (ParseException pe)
>         {
>             return null;
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.dspace.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Automate Storage Tiering Simply
Optimize IT performance and efficiency through flexible, powerful, 
automated storage tiering capabilities. View this brief to learn how
you can reduce costs and improve performance. 
http://p.sf.net/sfu/dell-sfdev2dev
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to