File tree Expand file tree Collapse file tree
server/src/main/java/org/elasticsearch/monitor/os Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -215,10 +215,20 @@ public Swap(long total, long free) {
215215 }
216216
217217 public Swap (StreamInput in ) throws IOException {
218- this .total = in .readLong ();
219- assert this .total >= 0 : "expected total swap to be positive, got: " + total ;
220- this .free = in .readLong ();
221- assert this .free >= 0 : "expected free swap to be positive, got: " + free ;
218+ long total = in .readLong ();
219+ assert total >= 0 : "expected total swap to be positive, got: " + total ;
220+ if (total < 0 ) {
221+ logger .error ("negative total swap [{}] deserialized in swap stats" , total );
222+ total = 0 ;
223+ }
224+ this .total = total ;
225+ long free = in .readLong ();
226+ assert free >= 0 : "expected free swap to be positive, got: " + free ;
227+ if (free < 0 ) {
228+ logger .error ("negative free swap [{}] deserialized in swap stats" , free );
229+ free = 0
230+ }
231+ this .free = free ;
222232 }
223233
224234 @ Override
You can’t perform that action at this time.
0 commit comments