You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Emmanuel Lecharny (JIRA)" <di...@incubator.apache.org> on 2005/09/02 09:05:16 UTC
[jira] Resolved: (DIRSNICKERS-106) DERGeneralizedTime and DERUTCTime are not thread safe
[ http://issues.apache.org/jira/browse/DIRSNICKERS-106?page=all ]
Emmanuel Lecharny resolved DIRSNICKERS-106:
-------------------------------------------
Resolution: Fixed
Assign To: Emmanuel Lecharny (was: Alex Karasulu)
All SimpleDateFormat usage have been synchronized all over the code.
> DERGeneralizedTime and DERUTCTime are not thread safe
> ------------------------------------------------------
>
> Key: DIRSNICKERS-106
> URL: http://issues.apache.org/jira/browse/DIRSNICKERS-106
> Project: Directory ASN1
> Type: Bug
> Components: BER Runtime
> Versions: 0.3.0
> Environment: Java version "1.5.0_04", Windows XP.
> Reporter: Tomi Keinonen
> Assignee: Emmanuel Lecharny
>
> Both classes DERGeneralizedTime and DERUTCTime include a static definition for date format:
> private static final SimpleDateFormat dateFormat = new SimpleDateFormat( "yyMMddHHmmss'Z'" );
> Static attribute is used by method:
> public Date getDate()
> throws ParseException
> {
> String string = byteArrayToString( value );
> return dateFormat.parse( string );
> }
> This fails when multiple threads access getDate concurrently. Calling dateFormat.parse is not synchronized and class SimpleDateFormat is not internally syncronized. JavaDoc for SimpleDateFormat says:
> "Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally."
> This causes not to be able to parse multiple DER streams concurrently and limits their usage in server environment.
> Without synchronization dateFormat.parse causes unpredictable errors. For example:
> ---
> java.lang.NumberFormatException: For input string: ".1212"
> at java.lang.NumberFormatException.forInputString(Unknown Source)
> at java.lang.Long.parseLong(Unknown Source)
> at java.lang.Long.parseLong(Unknown Source)
> at java.text.DigitList.getLong(Unknown Source)
> at java.text.DecimalFormat.parse(Unknown Source)
> at java.text.SimpleDateFormat.subParse(Unknown Source)
> at java.text.SimpleDateFormat.parse(Unknown Source)
> at java.text.DateFormat.parse(Unknown Source)
> at org.apache.asn1.der.DERGeneralizedTime.getDate(DERGeneralizedTime.java:68)
> ---
> java.lang.NumberFormatException: For input string: ""
> at java.lang.NumberFormatException.forInputString(Unknown Source)
> at java.lang.Long.parseLong(Unknown Source)
> at java.lang.Long.parseLong(Unknown Source)
> at java.text.DigitList.getLong(Unknown Source)
> at java.text.DecimalFormat.parse(Unknown Source)
> at java.text.SimpleDateFormat.subParse(Unknown Source)
> at java.text.SimpleDateFormat.parse(Unknown Source)
> at java.text.DateFormat.parse(Unknown Source)
> at org.apache.asn1.der.DERGeneralizedTime.getDate(DERGeneralizedTime.java:68)
> ---
> java.lang.ArrayIndexOutOfBoundsException: -1
> at java.text.DigitList.fitsIntoLong(Unknown Source)
> at java.text.DecimalFormat.parse(Unknown Source)
> at java.text.SimpleDateFormat.subParse(Unknown Source)
> at java.text.SimpleDateFormat.parse(Unknown Source)
> at java.text.DateFormat.parse(Unknown Source)
> at org.apache.asn1.der.DERGeneralizedTime.getDate(DERGeneralizedTime.java:68)
> ---
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira