Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 58615 invoked from network); 19 Feb 2008 10:17:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Feb 2008 10:17:13 -0000 Received: (qmail 36711 invoked by uid 500); 19 Feb 2008 10:17:06 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 36683 invoked by uid 500); 19 Feb 2008 10:17:06 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 36674 invoked by uid 99); 19 Feb 2008 10:17:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Feb 2008 02:17:06 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of alexei.zakharov@gmail.com designates 209.85.146.178 as permitted sender) Received: from [209.85.146.178] (HELO wa-out-1112.google.com) (209.85.146.178) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Feb 2008 10:16:34 +0000 Received: by wa-out-1112.google.com with SMTP id k22so3515939waf.18 for ; Tue, 19 Feb 2008 02:16:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=G158THM9HM2/FPKnH4PJSb6ADOAf9WYMX9I++a+2mxk=; b=d463dRUgwltDpQEFM4jhu8beIMlfUEM0h6Iqf3i2pw3L3+bM6r49/MFlfa9VgYKYILgqISSaRsCnVzPd1zkM3Aic8EVHy5w/q5/N/RWnlcD2GxdjhHgwWj7l75WZ9gW5BaXqwH50hAqMk396/KBJMfs1Y1DWee+kU+WSnQ6Yqrc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=FplmsIJkLcJZ0Mg8RkBdiqjkAx2LWbMPRlFx66c0lrgOwKarYUZbcAfAkH49U9OtlKUb2M//+M1VxHCkaEKmlKWllQaASmaYHkepbJPeIze0ZnfMPR4LTTS5aGLwa848cVIYYY1qyxKnsddjNAjZErgtpL/OxJE0of/BZXGJ1vo= Received: by 10.114.58.1 with SMTP id g1mr6385916waa.91.1203416202534; Tue, 19 Feb 2008 02:16:42 -0800 (PST) Received: by 10.114.198.16 with HTTP; Tue, 19 Feb 2008 02:16:42 -0800 (PST) Message-ID: <2c9597b90802190216l255482a6h5dc3585e8c56bb01@mail.gmail.com> Date: Tue, 19 Feb 2008 13:16:42 +0300 From: "Alexei Zakharov" To: dev@harmony.apache.org Subject: Re: [Approval] Commit Harmony-5460 In-Reply-To: <211709bc0802190115q38faf439ra1a6b6125ebd29b2@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <211709bc0802190115q38faf439ra1a6b6125ebd29b2@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi Tony, Don't you think that placing a synchronized block around the existing code would be a more transparent fix rather than simply redirecting all job to ICU? I mean something like this: Index: src/main/java/java/text/MessageFormat.java =================================================================== --- src/main/java/java/text/MessageFormat.java (revision 628711) +++ src/main/java/java/text/MessageFormat.java (working copy) @@ -446,6 +446,8 @@ * when the pattern cannot be parsed */ public static String format(String template, Object... objects) { + String result; + if (objects != null) { for (int i = 0; i < objects.length; i++) { if (objects[i] == null) { @@ -453,12 +455,16 @@ } } } - if (format == null) { - format = new com.ibm.icu.text.MessageFormat(template); - } else if (!template.equals(format.toPattern())){ - format.applyPattern(template); + synchronized (MessageFormat.class) { + if (format == null) { + format = new com.ibm.icu.text.MessageFormat(template); + } else if (!template.equals(format.toPattern())){ + format.applyPattern(template); + } + result = format.format(objects); } - return format.format(objects); + + return result; } /** Thanks, Alexei 2008/2/19, Tony Wu : > This is a major problem which blocks MessageFormat running on > multi-thread platform. It fails because the caching in Harmony does > not work with ICU4j 3.8.1. I suggest to commit this patch for M5. > > -- > Tony Wu > China Software Development Lab, IBM >