Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 90807 invoked from network); 1 Sep 2005 09:58:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Sep 2005 09:58:20 -0000 Received: (qmail 34696 invoked by uid 500); 1 Sep 2005 09:58:07 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 34656 invoked by uid 500); 1 Sep 2005 09:58:07 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 34640 invoked by uid 99); 1 Sep 2005 09:58:07 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Sep 2005 02:58:06 -0700 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id D62EFE0 for ; Thu, 1 Sep 2005 11:58:05 +0200 (CEST) Message-ID: <998176189.1125568685874.JavaMail.jira@ajax.apache.org> Date: Thu, 1 Sep 2005 11:58:05 +0200 (CEST) From: "Tomi Keinonen (JIRA)" To: dev@directory.apache.org Subject: [jira] Created: (DIRSNICKERS-106) DERGeneralizedTime and DERUTCTime are not thread safe Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 Assigned to: Alex Karasulu 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