Skip to content

Commit

Permalink
8209880: tzdb.dat is not reproducibly built
Browse files Browse the repository at this point in the history
Reviewed-by: clanger
Backport-of: e71557a
  • Loading branch information
RealLucy committed May 10, 2023
1 parent 1f49004 commit 2995d08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Expand Up @@ -65,8 +65,6 @@
import java.text.ParsePosition;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
Expand All @@ -76,6 +74,7 @@
import java.util.regex.Matcher;
import java.util.regex.MatchResult;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
* A compiler that reads a set of TZDB time-zone files and builds a single
Expand Down Expand Up @@ -256,8 +255,10 @@ private void outputFile(Path dstFile, String version,
for (String regionId : regionArray) {
out.writeUTF(regionId);
}
// rules -- hashset -> remove the dup
List<ZoneRules> rulesList = new ArrayList<>(new HashSet<>(builtZones.values()));
// rules -- remove the dup
List<ZoneRules> rulesList = builtZones.values().stream()
.distinct()
.collect(Collectors.toList());
out.writeShort(rulesList.size());
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
for (ZoneRules rules : rulesList) {
Expand Down
12 changes: 6 additions & 6 deletions make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java
Expand Up @@ -33,7 +33,7 @@
import java.nio.file.Paths;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.time.*;
import java.time.Year;
import java.time.chrono.IsoChronology;
Expand Down Expand Up @@ -119,18 +119,18 @@ public ZoneRules getZoneRules(String zoneId) {
/**
* Zone region to rules mapping
*/
private final Map<String, Object> zones = new ConcurrentHashMap<>();
private final Map<String, Object> zones = new ConcurrentSkipListMap<>();

/**
* compatibility list
*/
private static HashSet<String> excludedZones;
private static Set<String> excludedZones;
static {
// (1) exclude EST, HST and MST. They are supported
// via the short-id mapping
// (2) remove UTC and GMT
// (3) remove ROC, which is not supported in j.u.tz
excludedZones = new HashSet<>(10);
excludedZones = new TreeSet<>();
excludedZones.add("EST");
excludedZones.add("HST");
excludedZones.add("MST");
Expand All @@ -139,8 +139,8 @@ public ZoneRules getZoneRules(String zoneId) {
excludedZones.add("ROC");
}

private Map<String, String> links = new HashMap<>(150);
private Map<String, List<RuleLine>> rules = new HashMap<>(500);
private Map<String, String> links = new TreeMap<>();
private Map<String, List<RuleLine>> rules = new TreeMap<>();

private void load(List<Path> files) throws IOException {

Expand Down

1 comment on commit 2995d08

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.