Fix DataChangedJournalTest.equals().
Problems: 1. The class implemented equals() but not hashCode() 2. equals() attempted to canonicalize the underlying path and silently returned false if the I/O operation failed. Fixes: 1. Implemented hashCode(). 2. Stopped equals() attempting canonicalization and built in directly on top of File.equals() instead. I also considered moving the canonicalization to the DataChangedJournal ctor, but that - had the undesirable side effect of stopping interaction with the journal for reasons other than the file itself being corrupt, and - posed the problem of what to do in case of an IOException during construction. The downside of course is that caller which (inappropriately) relied on equals() doing canonicalization can no longer rely on that. I didn't find any such callers. Note: When DateChangedJournal.listJournals() fails to perform a directory listing (e.g. if the journal directory doesn't exist), it currently still returns an (empty) ArrayList<DateChangedJournal>. This CL does not address this, but in a follow-up CL I might change this to return an unmodifiable List or Set<DateChangedJournal>, and throw an IOException if the directory contents can't be listed. Bug: 162022005 Test: atest FrameworksServicesTests:com.android.server.backup.DataChangedJournalTest Change-Id: I94f35f9a3082f398758fe5b03fb8d260e4fb3e1b
Loading
Please register or sign in to comment