Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ private class OrganizationToValueAndVote<T> {
private final Map<Organization, T> orgToAdd = new EnumMap<>(Organization.class);

private T baileyValue;
private boolean baileySet; // was the bailey value set
private boolean baileySet; // was the bailey value set (possibly to null)

OrganizationToValueAndVote() {
for (Organization org : Organization.values()) {
Expand Down Expand Up @@ -1011,16 +1011,15 @@ public void clear() {
* Get the bailey value (what the inherited value would be if there were no explicit value) for
* this VoteResolver.
*
* <p>Throw an exception if !baileySet.
* <p>Throw an exception if !baileySet, in order to detect programming errors where
* getBaileyValue might be called before setBaileyValue.
*
* @return the bailey value.
* <p>Called by STFactory.PerLocaleData.getResolverInternal in the special circumstance
* where getWinningValue has returned INHERITANCE_MARKER.
* @return the bailey value (which may be null).
*/
public T getBaileyValue() {
private T getBaileyValue() {
if (!organizationToValueAndVote.baileySet) {
throw new IllegalArgumentException(
"setBaileyValue must be called before getBaileyValue");
"setBaileyValue must be called before getBaileyValue (even if the value is null)");
}
return organizationToValueAndVote.baileyValue;
}
Expand All @@ -1029,8 +1028,11 @@ public T getBaileyValue() {
* Set the Bailey value (what the inherited value would be if there were no explicit value).
* This value is used in handling any CldrUtility.INHERITANCE_MARKER. This value must be set
* <i>before</i> adding values. Usually by calling CLDRFile.getBaileyValue().
*
* @param baileyValue the value to be set, or null
*/
public void setBaileyValue(T baileyValue) {
// baileySet gets true here, even if baileyValue is null
organizationToValueAndVote.baileySet = true;
organizationToValueAndVote.baileyValue = baileyValue;
}
Expand Down Expand Up @@ -1208,7 +1210,7 @@ private void resolveVotes() {

/*
* If there are no (unconflicted) votes, return baseline (trunk) if not null,
* else INHERITANCE_MARKER if baileySet, else NO_WINNING_VALUE.
* else INHERITANCE_MARKER if baileyValue isn't null, else NO_WINNING_VALUE.
* Avoid setting winningValue to null. VoteResolver should be fully in charge of vote resolution.
*/
if (sortedValues.size() == 0) {
Expand All @@ -1219,7 +1221,7 @@ private void resolveVotes() {
"Winning Value: '%s' with status '%s' because there were no unconflicted votes.",
winningValue, winningStatus);
// Declare the winner here, because we're about to return from the function
} else if (organizationToValueAndVote.baileySet) {
} else if (getBaileyValue() != null) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the essential bug fix

setWinningValue((T) CldrUtility.INHERITANCE_MARKER);
winningStatus = Status.missing;
annotateTranscript(
Expand Down Expand Up @@ -1343,11 +1345,10 @@ private HashMap<T, Long> makeVoteCountMap(Set<T> sortedValues) {
*/
private boolean combineInheritanceWithBaileyForVoting(
Set<T> sortedValues, HashMap<T, Long> voteCount) {
if (organizationToValueAndVote.baileySet == false
|| organizationToValueAndVote.baileyValue == null) {
T hardValue = getBaileyValue();
if (hardValue == null) {
return false;
}
T hardValue = organizationToValueAndVote.baileyValue;
T softValue = (T) CldrUtility.INHERITANCE_MARKER;
/*
* Check containsKey before get, to avoid NullPointerException.
Expand Down Expand Up @@ -1875,8 +1876,8 @@ public Map<String, Long> getNameTime() {
public String toString() {
return "{"
+ "bailey: "
+ (organizationToValueAndVote.baileySet
? ("“" + organizationToValueAndVote.baileyValue + "” ")
+ (organizationToValueAndVote.baileyValue != null
? ("“" + getBaileyValue() + "” ")
: "none ")
+ "baseline: {"
+ baselineValue
Expand Down Expand Up @@ -2159,9 +2160,9 @@ private boolean equalsOrgVote(T value, T orgVote) {
return orgVote == null
|| orgVote.equals(value)
|| (CldrUtility.INHERITANCE_MARKER.equals(value)
&& orgVote.equals(organizationToValueAndVote.baileyValue))
&& orgVote.equals(getBaileyValue()))
|| (CldrUtility.INHERITANCE_MARKER.equals(orgVote)
&& value.equals(organizationToValueAndVote.baileyValue));
&& value.equals(getBaileyValue()));
}

/**
Expand Down
Loading