make sure that mem, cpu and swap are never null in OsStats

This commit is contained in:
javanna 2016-09-01 11:23:07 +02:00 committed by Luca Cavanna
parent 5f299ff46f
commit 042675432e
1 changed files with 4 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
public class OsStats implements Writeable, ToXContent { public class OsStats implements Writeable, ToXContent {
@ -38,9 +39,9 @@ public class OsStats implements Writeable, ToXContent {
public OsStats(long timestamp, Cpu cpu, Mem mem, Swap swap) { public OsStats(long timestamp, Cpu cpu, Mem mem, Swap swap) {
this.timestamp = timestamp; this.timestamp = timestamp;
this.cpu = cpu; this.cpu = Objects.requireNonNull(cpu, "cpu must not be null");
this.mem = mem; this.mem = Objects.requireNonNull(mem, "mem must not be null");;
this.swap = swap; this.swap = Objects.requireNonNull(swap, "swap must not be null");;
} }
public OsStats(StreamInput in) throws IOException { public OsStats(StreamInput in) throws IOException {