Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 16252 invoked from network); 1 Feb 2006 10:38:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Feb 2006 10:38:36 -0000 Received: (qmail 18591 invoked by uid 500); 1 Feb 2006 10:38:30 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 18479 invoked by uid 500); 1 Feb 2006 10:38:29 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 18465 invoked by uid 99); 1 Feb 2006 10:38:28 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= 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; Wed, 01 Feb 2006 02:38:24 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 30AF3C9 for ; Wed, 1 Feb 2006 11:38:03 +0100 (CET) Message-ID: <1275429683.1138790283089.JavaMail.jira@ajax.apache.org> Date: Wed, 1 Feb 2006 11:38:03 +0100 (CET) From: "tatyana doubtsova (JIRA)" To: harmony-dev@incubator.apache.org Subject: [jira] Created: (HARMONY-65) java.text.MessageFormat.applyPattern(String pattern) and two MessageFormat constructors fail to detect unmatched braces in the pattern 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 java.text.MessageFormat.applyPattern(String pattern) and two MessageFormat constructors fail to detect unmatched braces in the pattern -------------------------------------------------------------------------------------------------------------------------------------- Key: HARMONY-65 URL: http://issues.apache.org/jira/browse/HARMONY-65 Project: Harmony Type: Bug Components: Classlib Reporter: tatyana doubtsova Problem details: According to j2se 1.4.2 constructors MessageFormat(String pattern), MessageFormat(String pattern, Locale) and method applyPattern(String pattern) should throw IllegalArgumantException, if the pattern is invalid. Harmony implementation doesn't throw IAE, when there are unmatched braces in the pattern Code for reproducing Test.java: import java.text.*; import java.util.Locale; public class Test { public static void main(String[] args) throws Exception { MessageFormat mf = new MessageFormat("{0,number,integer}"); String badpattern = "{0,number,#"; try{ mf.applyPattern(badpattern); System.out.println("pattern = " + mf.toPattern()); System.out.println("applyPattern(String) FAILED to detect invalid pattern"); } catch (IllegalArgumentException e) { System.out.println(e.getMessage()); System.out.println("applyPattern(String) PASSED"); System.out.println(e.getMessage()); } try { mf = new MessageFormat("{0,number,integer"); System.out.println("pattern = " + mf.toPattern()); System.out.println("MessageFormat(String) FAILED to detect invalid pattern"); } catch (IllegalArgumentException e) { System.out.println(e.getMessage()); System.out.println("MessageFormat(String) PASSED"); } try { mf = new MessageFormat("{0,number,integer", Locale.US); System.out.println("pattern = " + mf.toPattern()); System.out.println("MessageFormat(String, Locale) FAILED to detect invalid pattern"); } catch (IllegalArgumentException e) { System.out.println(e.getMessage()); System.out.println("MessageFormat(String, Locale) PASSED"); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile Test.java using BEA 1.4 javac > javac -d . Test.java 3. Run java using compatible VM (J9) > java -showversion Test Output: java version 1.4.2 (subset) (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. pattern = {0,number,#} applyPattern(String) FAILED to detect invalid pattern pattern = {0,number,integer#} MessageFormat(String) FAILED to detect invalid pattern pattern = {0,number,integer#} MessageFormat(String, Locale) FAILED to detect invalid pattern Output on BEA 1.4.2 to compare with: Unmatched braces in the pattern. applyPattern(String) PASSED Unmatched braces in the pattern. Unmatched braces in the pattern. MessageFormat(String) PASSED Unmatched braces in the pattern. MessageFormat(String, Locale) PASSED Suggested junit test case: package org.apache.harmony.tests.java.text; import java.text.MessageFormat; import java.util.Locale; import junit.framework.TestCase; public class MessageFormatTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(MessageFormatTest.class); } public void test_MessageFormatString() { try { MessageFormat mf = new MessageFormat("{0,number,integer"); fail("Assert 0: Failed to detect unmatched brackets."); } catch (IllegalArgumentException e) { } } public void test_MessageFormatStringLocale() { try { MessageFormat mf = new MessageFormat("{0,number,integer", Locale.US); fail("Assert 0: Failed to detect unmatched brackets."); } catch (IllegalArgumentException e) { } } public void test_applyPatternString() { MessageFormat mf = new MessageFormat("{0,number,integer}"); String badpattern = "{0,number,#"; try{ mf.applyPattern(badpattern); fail("Assert 0: Failed to detect unmatched brackets."); } catch (IllegalArgumentException e) { } } } -- 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