8008161: Regression: j.u.TimeZone.getAvailableIDs(rawOffset) returns non-sorted list
Summary: to return a sorted list
Reviewed-by: lancea, naoto
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java Wed Feb 13 19:40:51 2013 +0000
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java Wed Feb 13 11:49:34 2013 -0800
@@ -92,7 +92,13 @@
ids.add(id);
}
}
- return ids.toArray(new String[ids.size()]);
+ // It appears the "zi" implementation returns the
+ // sorted list, though the specification does not
+ // specify it. Keep the same behavior for better
+ // compatibility.
+ String[] list = ids.toArray(new String[ids.size()]);
+ Arrays.sort(list);
+ return list;
}
public static ZoneInfo getZoneInfo(String zoneId) {
--- a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java Wed Feb 13 19:40:51 2013 +0000
+++ b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java Wed Feb 13 11:49:34 2013 -0800
@@ -23,7 +23,7 @@
/*
*@test
- *@bug 8007572
+ *@bug 8007572 8008161
*@summary Test whether the TimeZone generated from JSR310 tzdb is the same
*as the one from the tz data from javazic
*/
@@ -156,6 +156,24 @@
sun.util.calendar.ZoneInfoFile.getVersion(), ver);
throw new RuntimeException("Version test failed");
}
+
+ // test getAvailableIDs(raw);
+ zids_new = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
+ //Arrays.sort(zids_new);
+ zids_old = ZoneInfoOld.getAvailableIDs(-8 * 60 * 60 * 1000);
+ if (!Arrays.equals(zids_new, zids_old)) {
+ System.out.println("------------------------");
+ System.out.println("NEW.getAvailableIDs(-8:00)");
+ for (String zid : zids_new) {
+ System.out.println(zid);
+ }
+ System.out.println("------------------------");
+ System.out.println("OLD.getAvailableIDs(-8:00)");
+ for (String zid : zids_old) {
+ System.out.println(zid);
+ }
+ throw new RuntimeException(" FAILED: availableIds(offset) don't match");
+ }
}
private static void delete(File f) {