Fix a null check bug in HostUpdateFlow

This bug is about a bad use of Optional.
We were checking == null instead of .isPresent(), so the check
always passed, and we always set a lastSubordinateTime when
updating hosts, even if the host was external and should have
had a null value in that field.

There is almost certainly bad data in prod in the sense
that any external host that was ever updated will have a value
for this field instead of null. However, this is not
consequential as the field is entirely meaningless for
external hosts, and will be properly reset if the host is
ever moved to be internal.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=146363178
This commit is contained in:
cgoldfeder 2017-02-02 07:52:37 -08:00 committed by Ben McIlwain
parent a3baa58cad
commit 223e8c2316
2 changed files with 3 additions and 1 deletions

View file

@ -562,6 +562,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
// The last transfer time should be what was on the superordinate domain at the time of the host
// update, not what it is later changed to.
assertThat(renamedHost.getLastTransferTime()).isEqualTo(lastTransferTime);
// External hosts should always have null lastSuperordinateChange.
assertThat(renamedHost.getLastSuperordinateChange()).isNull();
}
@Test