Fix NPE when loading IntraLineDiff from disk cache

We failed to populate the list member, which resulted in the
IntraLineDiff crashing with NPE when it was loaded from the disk
cache after a graceful server restart.

Change-Id: Iff5a49d8de26df6c89cb56e1086d35838e71e5b4
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-11-15 11:27:38 -08:00
parent 8dc6ca89e8
commit ef3dda7f37
2 changed files with 6 additions and 4 deletions

View File

@@ -33,10 +33,10 @@ import java.util.List;
public class IntraLineDiff implements Serializable {
static final long serialVersionUID = IntraLineDiffKey.serialVersionUID;
private List<Edit> edits;
private transient List<Edit> edits;
IntraLineDiff(List<Edit> edits) {
this.edits = edits;
this.edits = Collections.unmodifiableList(edits);
}
public List<Edit> getEdits() {
@@ -69,11 +69,13 @@ public class IntraLineDiff implements Serializable {
int innerCount = readVarInt32(in);
if (0 < innerCount) {
Edit[] inner = new Edit[innerCount];
for (int j = 0; j < innerCount; j++)
for (int j = 0; j < innerCount; j++) {
inner[j] = readEdit(in);
}
editArray[i] = new ReplaceEdit(editArray[i], toList(inner));
}
}
edits = toList(editArray);
}
private static void writeEdit(OutputStream out, Edit e) throws IOException {