From 4eca0bba1aac5b62e36ed4118ac7b55a09f3eba9 Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Thu, 25 Feb 2010 22:11:15 +0000 Subject: [PATCH] ICU-6444 Fixed a metazone golden zone mapping problem caused by its cache logic. To fix this problem, I updated the data structure of mapTimezones. This change was done in CLDR svn revision 4748 and ICU4C r27683. Regenerate ICU4J data using ICU4C r27683 and fixed the caching problem described above. X-SVN-Rev: 27684 --- .../core/src/com/ibm/icu/impl/ZoneMeta.java | 51 +++++++++---------- icu4j/main/shared/data/icudata.jar | 4 +- icu4j/main/shared/data/testdata.jar | 4 +- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java index 9006e7894de..2a2c4d75ff7 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java @@ -12,9 +12,12 @@ package com.ibm.icu.impl; import java.text.ParsePosition; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.MissingResourceException; +import java.util.Set; import com.ibm.icu.text.MessageFormat; import com.ibm.icu.text.NumberFormat; @@ -887,44 +890,40 @@ public final class ZoneMeta { return date; } - private static ICUCache META_TO_OLSON_CACHE = - new SimpleCache(); + private static ICUCache> META_TO_OLSON_CACHE = + new SimpleCache>(); /** * Returns an Olson ID for the ginve metazone and region */ public static String getZoneIdByMetazone(String metazoneID, String region) { String tzid = null; - String keyWithRegion = (region == null || region.length() == 0) ? null : metazoneID + ":" + region; // look up in the cache first - if (keyWithRegion != null) { - tzid = META_TO_OLSON_CACHE.get(metazoneID + ":" + region); - } - if (tzid == null) { - tzid = META_TO_OLSON_CACHE.get(metazoneID); - } - - // look up in the resource bundle - if (tzid == null) { + Map zoneMap = META_TO_OLSON_CACHE.get(metazoneID); + if (zoneMap == null) { try { + // Create zone mappings for the metazone UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "metaZones"); UResourceBundle mapTimezones = bundle.get("mapTimezones"); + UResourceBundle territoryMap = mapTimezones.get(metazoneID); + zoneMap = new HashMap(); + Set territories = territoryMap.keySet(); + for (String territory : territories) { + String zone = territoryMap.getString(territory); + zoneMap.put(territory, zone); + } + // cache this + META_TO_OLSON_CACHE.put(metazoneID, zoneMap); + } catch (MissingResourceException e) { + // ignore + } + } - if (keyWithRegion != null) { - try { - tzid = mapTimezones.getString(keyWithRegion); - META_TO_OLSON_CACHE.put(keyWithRegion, tzid); - } catch (MissingResourceException e) { - // fall through - } - } - if (tzid == null) { - tzid = mapTimezones.getString(metazoneID); - META_TO_OLSON_CACHE.put(metazoneID, tzid); - } - } catch (MissingResourceException mre) { - // do nothing + if (zoneMap != null) { + tzid = zoneMap.get(region); + if (tzid == null) { + tzid = zoneMap.get("001"); // use the mapping for world as fallback } } diff --git a/icu4j/main/shared/data/icudata.jar b/icu4j/main/shared/data/icudata.jar index db8de29ad07..4714507246c 100755 --- a/icu4j/main/shared/data/icudata.jar +++ b/icu4j/main/shared/data/icudata.jar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c91928adc02dbc1c42de92376b32ca1828ea1cebe96ceb055b9f42936d46e799 -size 7005679 +oid sha256:fbb4f47e1846a07e115a7847d85ee8ccf44469af34ecf1780d60aa5f8eacdf74 +size 7006452 diff --git a/icu4j/main/shared/data/testdata.jar b/icu4j/main/shared/data/testdata.jar index 18dc8ef0c5f..89f32451b8c 100755 --- a/icu4j/main/shared/data/testdata.jar +++ b/icu4j/main/shared/data/testdata.jar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5fc863cb115c8fe4c2da78ea3539fd04f57ca8f871a48c23ed3b50c55ee0991c -size 720307 +oid sha256:23766c7d13e3b01a78b9b0e54bbb7bf71a41bf9fe7cee13fda36ee9f8b34d70a +size 720308