Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale deserialize 'zh-hant_CN' #1411

Closed
takeseem opened this issue Feb 28, 2018 · 4 comments
Closed

Locale deserialize 'zh-hant_CN' #1411

takeseem opened this issue Feb 28, 2018 · 4 comments

Comments

@takeseem
Copy link
Contributor

takeseem commented Feb 28, 2018

zh-hant_CN will convert to zh_HANT_cn

Locale include (language, country, variant), Locale.toString() use '_' to split then {language}_{country}_({variant}_# | #){script}-{extensions}

but Jackson deserialize Locale use '-' or '_' : (
code: LocaleHandle.readResolve()

iana language-tags

zh-Hant	Chinese, in traditional script	[Mark_Davis][Mark_Davis_2]	
zh-Hant-CN	PRC Mainland Chinese in traditional script	[Mark_Davis][Mark_Davis_2]	
zh-Hant-HK	Hong Kong Chinese in traditional script	[Mark_Davis][Mark_Davis_2]	
zh-Hant-MO	Macao Chinese in traditional script	[Mark_Davis][Mark_Davis_2]	
zh-Hant-SG	Singapore Chinese in traditional script	[Mark_Davis][Mark_Davis_2]	
zh-Hant-TW	Taiwan Chinese in traditional script	[Mark_Davis][Mark_Davis_2]

rfc4647 language lookup

  Example of a Lookup Fallback Pattern

   Range to match: zh-Hant-CN-x-private1-private2
   1. zh-Hant-CN-x-private1-private2
   2. zh-Hant-CN-x-private1
   3. zh-Hant-CN
   4. zh-Hant
   5. zh
   6. (default)
	public static void main(String[] args) {
		System.out.println(new Locale("zh-hant", "CN"));
	}

in jdk1.5 -> 1.8

jdk1.5	zh-hant_CN
jdk1.6	zh-hant_CN
jdk1.7	zh-hant_CN
jdk1.8	zh-hant_CN
@beiwei30
Copy link
Member

beiwei30 commented Mar 1, 2018

one more comments: if user starts to complain the inter-op compatibility between old dubbo version and current version, we may need to consider to rollback change 0423219, or consider to introduce a system property to control the behavior.

@takeseem
Copy link
Contributor Author

takeseem commented Mar 1, 2018

我优化了代码,英文太差直接中文:(

commit 844d7c7

public class LocaleHandle implements java.io.Serializable, HessianHandle {
    private String value;

    public LocaleHandle(String locale) {
        this.value = locale;
    }

    private Object readResolve() {
        if (value == null) {
            return null;
        }

        if (value.length() == 0) {
            return new Locale("");
        }

        int extStart = value.indexOf("_#");
        if (extStart != -1) value = value.substring(0, extStart);

        String language = value, country = "", variant = "";
        int pos1 = value.indexOf('_');
        if (pos1 != -1) {
            language = value.substring(0, pos1++);

            int pos2 = value.indexOf('_', pos1);
            if (pos2 == -1) {
                country = value.substring(pos1);
            } else {
                country = value.substring(pos1, pos2);
                variant = value.substring(pos2 + 1);
            }
        }
        return new Locale(language, country, variant);
    }
}

@vihunk
Copy link

vihunk commented Mar 1, 2018

The code's readability needs to improve.

zonghaishang pushed a commit to zonghaishang/dubbo that referenced this issue Mar 2, 2018
* @reference support annotate on annotation type

* Fixes apache#1303 TimeUnit conversion error

* Fixes apache#1289, use bind_port as mapping key

* Fixes apache#1313, remove destroy check in Registry.

* checkout .travis.yml from origin/master

* Fix hessian2 serialized short, byte is converted to int bug (apache#1232)

* Fix hessian2 serialized short, byte is converted to int bug

* Fix hessian2 serialized short, byte is converted to int bug

* adapt jdk1.5+

* fixed travis-ci failed because of test cases. (apache#1370)

* Merge pull request apache#1377, remove redundant arguments for StatItem.isAllowable()

* Merge pull request apache#1378, replace StringBuider with simple string concatenation in log.

* Merge pull request apache#1375, remove unnecessary boxing.

Fixes apache#1245

* Merge pull request apache#1331, add optional parameter to support hessian protocol method overload and request protocol version.

* Merge pull request apache#1376, do not instantiate load balance if there is no invokers

Fixes apache#1297

* Merge pull request apache#1384, fix build string bug.

* Merge pull request apache#1040, refactor: replace some deprecated methods related with jedis.

* Merge pull request apache#1242, remove redundant null check.

fixes apache#1231

* Change Mailing list address

* Fixed apache#1398, revert bugs introduced from apache#1375

* Fix time unit problem in UT

* Fix time unit problem related with FutureAdapter in UT

* Fix time unit problem related with FutureAdapter in UT

* Merge pull request apache#1391, fix typo of method name in qos module.

* fix hessian lite test case fail bug (apache#1394)

* fix hessian lite test case fail bug

* update test

* remove ignore

* Fix time unit problem related with FutureAdapter in UT

* revert file

* fix number type is lost in yaml config file (apache#1401)

* apache#1399 fi

* update test

* update readme to add some details (apache#1403)

* update readme to add some details

update readme to add some details

* delete duplicated words

delete duplicated words

* update README format

*     apache#1411: Locale deserialize 'zh-hant_CN'
@takeseem
Copy link
Contributor Author

takeseem commented Mar 3, 2018

@vihunk 能否说的更加具体,比如直接在commit 376806a添加:comments。

xpylq pushed a commit to xpylq/dubbo that referenced this issue Mar 5, 2018
* remotes/upstream/master: (226 commits)
  clean up imports for CacheTest
  [Dubbo-apache#1362] cache provider always lru cache (apache#1396)
  Remove author info and add apache license
  Fix "promoteTransitiveDependencies=false" of maven-shade-plugin
  apache#1411: Locale deserialize 'zh-hant_CN'
  update README format
  update readme to add some details (apache#1403)
  fix number type is lost in yaml config file (apache#1401)
  fix hessian lite test case fail bug (apache#1394)
  Merge pull request apache#1391, fix typo of method name in qos module.
  Fix time unit problem related with FutureAdapter in UT
  Fix time unit problem related with FutureAdapter in UT
  Fix time unit problem in UT
  Fixed apache#1398, revert bugs introduced from apache#1375
  Change Mailing list address
  Merge pull request apache#1242, remove redundant null check.
  Merge pull request apache#1040, refactor: replace some deprecated methods related with jedis.
  Merge pull request apache#1384, fix build string bug.
  Merge pull request apache#1376, do not instantiate load balance if there is no invokers
  Merge pull request apache#1331, add optional parameter to support hessian protocol method overload and request protocol version.
  ...
takeseem added a commit to takeseem-com/dubbo that referenced this issue Mar 9, 2018
takeseem added a commit to takeseem-com/dubbo that referenced this issue Mar 9, 2018
rolandhe pushed a commit to rolandhe/dubbo that referenced this issue Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants