Skip to content

Commit 8a30262

Browse files
authored
fixes NPE with system compactions (apache#4263)
1 parent 4e1b052 commit 8a30262

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

core/src/main/java/org/apache/accumulo/core/metadata/schema/CompactionMetadata.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ public CompactionMetadata(Set<StoredTabletFile> jobFiles, ReferencedTabletFile c
5454
this.priority = priority;
5555
this.cgid = Objects.requireNonNull(ceid);
5656
this.propagateDeletes = propagateDeletes;
57-
this.fateId = fateId;
57+
if (kind == CompactionKind.SYSTEM) {
58+
// its ok if this is null for system compactions because its not used.
59+
this.fateId = fateId;
60+
} else {
61+
this.fateId = Objects.requireNonNull(fateId);
62+
}
5863
}
5964

6065
public Set<StoredTabletFile> getJobFiles() {
@@ -112,7 +117,7 @@ public String toJson() {
112117
jData.groupId = cgid.toString();
113118
jData.priority = priority;
114119
jData.propDels = propagateDeletes;
115-
jData.fateId = fateId.canonical();
120+
jData.fateId = fateId == null ? null : fateId.canonical();
116121
return GSON.get().toJson(jData);
117122
}
118123

@@ -122,7 +127,8 @@ public static CompactionMetadata fromJson(String json) {
122127
return new CompactionMetadata(jData.inputs.stream().map(StoredTabletFile::new).collect(toSet()),
123128
StoredTabletFile.of(jData.tmp).getTabletFile(), jData.compactor,
124129
CompactionKind.valueOf(jData.kind), jData.priority,
125-
CompactorGroupIdImpl.groupId(jData.groupId), jData.propDels, FateId.from(jData.fateId));
130+
CompactorGroupIdImpl.groupId(jData.groupId), jData.propDels,
131+
jData.fateId == null ? null : FateId.from(jData.fateId));
126132
}
127133

128134
@Override

0 commit comments

Comments
 (0)