Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 76309 invoked from network); 17 Feb 2006 16:10:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Feb 2006 16:10:00 -0000 Received: (qmail 38614 invoked by uid 500); 17 Feb 2006 16:09:49 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 38513 invoked by uid 500); 17 Feb 2006 16:09:49 -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 38466 invoked by uid 99); 17 Feb 2006 16:09:48 -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; Fri, 17 Feb 2006 08:09:46 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 8EF3FDC for ; Fri, 17 Feb 2006 17:09:25 +0100 (CET) Message-ID: <1478177728.1140192565550.JavaMail.jira@ajax.apache.org> Date: Fri, 17 Feb 2006 17:09:25 +0100 (CET) From: "Tim Ellison (JIRA)" To: harmony-dev@incubator.apache.org Subject: [jira] Assigned: (HARMONY-65) java.text.MessageFormat.applyPattern(String pattern) and two MessageFormat constructors fail to detect unmatched braces in the pattern In-Reply-To: <1275429683.1138790283089.JavaMail.jira@ajax.apache.org> 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 [ http://issues.apache.org/jira/browse/HARMONY-65?page=all ] Tim Ellison reassigned HARMONY-65: ---------------------------------- Assign To: Tim Ellison > 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 > Assignee: Tim Ellison > > 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