Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 367F6200C34 for ; Mon, 27 Feb 2017 14:22:53 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 350A8160B6C; Mon, 27 Feb 2017 13:22:53 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7E8F2160B60 for ; Mon, 27 Feb 2017 14:22:52 +0100 (CET) Received: (qmail 50229 invoked by uid 500); 27 Feb 2017 13:22:50 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 50211 invoked by uid 99); 27 Feb 2017 13:22:50 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Feb 2017 13:22:50 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id D3FF31A0505 for ; Mon, 27 Feb 2017 13:22:49 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.536 X-Spam-Level: X-Spam-Status: No, score=-1.536 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, LOTS_OF_MONEY=0.001, RP_MATCHES_RCVD=-2.999, SPF_NEUTRAL=0.652, T_FILL_THIS_FORM_SHORT=0.01] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Wgzfr-7RcKHA for ; Mon, 27 Feb 2017 13:22:48 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 14101618AC for ; Mon, 27 Feb 2017 13:22:48 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 05993E073C for ; Mon, 27 Feb 2017 13:22:46 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 4EA6F2413A for ; Mon, 27 Feb 2017 13:22:45 +0000 (UTC) Date: Mon, 27 Feb 2017 13:22:45 +0000 (UTC) From: "Rob Tompkins (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (TEXT-64) Investigate locale issue in ExtendedMessageFormatTest MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 27 Feb 2017 13:22:53 -0000 [ https://issues.apache.org/jira/browse/TEXT-64?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15885774#comment-15885774 ] Rob Tompkins commented on TEXT-64: ---------------------------------- We are comparing the results from {{java.text.MessageFormat}} with those from {{org.apache.commons.text.ExtendedMessageFormat}}, and there are slight differences when calling {{Locale.getDefault}}. Namely: {code:java} public MessageFormat(String pattern) { this.locale = Locale.getDefault(Locale.Category.FORMAT); applyPattern(pattern); } {code} versus {code:java} public ExtendedMessageFormat(final String pattern) { this(pattern, Locale.getDefault()); } {code} The key differences here in the {{Locale}} class reside in the {{initDefault}} method: {code:java} private static Locale initDefault() { String language, region, script, country, variant; language = AccessController.doPrivileged( new GetPropertyAction("user.language", "en")); // for compatibility, check for old user.region property region = AccessController.doPrivileged( new GetPropertyAction("user.region")); if (region != null) { // region can be of form country, country_variant, or _variant int i = region.indexOf('_'); if (i >= 0) { country = region.substring(0, i); variant = region.substring(i + 1); } else { country = region; variant = ""; } script = ""; } else { script = AccessController.doPrivileged( new GetPropertyAction("user.script", "")); country = AccessController.doPrivileged( new GetPropertyAction("user.country", "")); variant = AccessController.doPrivileged( new GetPropertyAction("user.variant", "")); } return getInstance(language, script, country, variant, null); } private static Locale initDefault(Locale.Category category) { return getInstance( AccessController.doPrivileged( new GetPropertyAction(category.languageKey, defaultLocale.getLanguage())), AccessController.doPrivileged( new GetPropertyAction(category.scriptKey, defaultLocale.getScript())), AccessController.doPrivileged( new GetPropertyAction(category.countryKey, defaultLocale.getCountry())), AccessController.doPrivileged( new GetPropertyAction(category.variantKey, defaultLocale.getVariant())), null); } {code} I suppose we could add the {{Locale.Category}} to the default locale creation, but as I'm unfamiliar with the mechanics here I plan to bubble this up to the ML. > Investigate locale issue in ExtendedMessageFormatTest > ----------------------------------------------------- > > Key: TEXT-64 > URL: https://issues.apache.org/jira/browse/TEXT-64 > Project: Commons Text > Issue Type: Bug > Affects Versions: 1.0-beta-1 > Reporter: Rob Tompkins > Fix For: 1.0 > > > During release testing, Bruno found the following problem, needing investigation, (http://markmail.org/message/hhio4ye2xlvdznlv). > /* --- snip -- */ > Results : > {code} > Failed tests: > ExtendedMessageFormatTest.testBuiltInChoiceFormat:211->checkBuiltInFormat:336->checkBuiltInFormat:347->checkBuiltInFormat:376 > format Pattern=[1234.5: {0,choice,1#One|2#Two|3#Many {0,number}}], locale=[null] > expected:<1234.5: Many 1[.234,]5> but was:<1234.5: Many 1[,234.]5> > ExtendedMessageFormatTest.testBuiltInDateTimeFormat:230->checkBuiltInFormat:336->checkBuiltInFormat:347->checkBuiltInFormat:376 > format Pattern=[1: {0,date,short}], locale=[null] expected:<1: [23/01]/07> but > was:<1: [1/23]/07> > ExtendedMessageFormatTest.testBuiltInNumberFormat:277->checkBuiltInFormat:336->checkBuiltInFormat:347->checkBuiltInFormat:376 > format Pattern=[1: {0,number}], locale=[null] expected:<1: 6[.543,]21> but > was:<1: 6[,543.]21> > ExtendedMessageFormatTest.testExtendedAndBuiltInFormats:141 null expected: JOHN DOE DOB: [23/01/07 Salary: R$ 12.345,]67> but was: [1/23/07 Salary: $12,345.]67> > ExtendedMessageFormatTest.testOverriddenBuiltinFormat:253->checkBuiltInFormat:347->checkBuiltInFormat:376 > format Pattern=[1: {0,date}], locale=[null] expected:<1: [23/01/]2007> but > was:<1: [Jan 23, ]2007> > Tests run: 476, Failures: 5, Errors: 0, Skipped: 0 > [INFO] ------------------------------------------------------------------------ > [INFO] BUILD FAILURE > [INFO] ------------------------------------------------------------------------ > [INFO] Total time: 11.385 s > [INFO] Finished at: 2017-02-06T14:07:52-02:00 > [INFO] Final Memory: 30M/328M > [INFO] ------------------------------------------------------------------------ > {code} > /* --- snip -- */ > Here's my env: > Apache Maven 3.3.9 > Maven home: /usr/share/maven > Java version: 1.8.0_111, vendor: Oracle Corporation > Java home: /usr/lib/jvm/java-8-oracle/jre > Default locale: en_US, platform encoding: UTF-8 > OS name: "linux", version: "4.4.0-59-generic", arch: "amd64", family: "unix" > Even though the JVM locale seems to be set to en_US, I'm in Brazil right now > with the time in Ubuntu set to local time, as well as the locale (or so I > think). Here's my output of running the `locale` command. > /* --- snip --- */ > $ locale > LANG=en_US.UTF-8 > LANGUAGE=en_US > LC_CTYPE=pt_BR.UTF-8 > LC_NUMERIC=pt_BR.UTF-8 > LC_TIME=pt_BR.UTF-8 > LC_COLLATE="en_US.UTF-8" > LC_MONETARY=pt_BR.UTF-8 > LC_MESSAGES="en_US.UTF-8" > LC_PAPER=pt_BR.UTF-8 > LC_NAME=pt_BR.UTF-8 > LC_ADDRESS=pt_BR.UTF-8 > LC_TELEPHONE=pt_BR.UTF-8 > LC_MEASUREMENT=pt_BR.UTF-8 > LC_IDENTIFICATION=pt_BR.UTF-8 > LC_ALL= > /* --- snip --- */ -- This message was sent by Atlassian JIRA (v6.3.15#6346)