提交 36d8b92a 编写于 作者: I igerasim

8189284: More refactoring for deserialization cases

Reviewed-by: rriggs, igerasim, rhalade, skoivu
上级 d32ec30a
......@@ -1414,4 +1414,30 @@ public class ArrayBlockingQueue<E> extends AbstractQueue<E>
Spliterator.CONCURRENT);
}
/**
* Deserializes this queue and then checks some invariants.
*
* @param s the input stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws java.io.InvalidObjectException if invariants are violated
* @throws java.io.IOException if an I/O error occurs
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
// Read in items array and various fields
s.defaultReadObject();
// Check invariants over count and index fields. Note that
// if putIndex==takeIndex, count can be either 0 or items.length.
if (items.length == 0 ||
takeIndex < 0 || takeIndex >= items.length ||
putIndex < 0 || putIndex >= items.length ||
count < 0 || count > items.length ||
Math.floorMod(putIndex - takeIndex, items.length) !=
Math.floorMod(count, items.length)) {
throw new java.io.InvalidObjectException("invariants violated");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册