Validates the cached hashCode after deserialization. Throws a InvalidObjectException when the stored hashCode does not match the canonical hash of the deserialized minimum/maximum. @param in See Serializable. @throws IOException See Serializable. @throws ClassNotF
(final ObjectInputStream in)
| 544 | * @throws InvalidObjectException If the hashCode doesn't match the minimum and maximum. |
| 545 | */ |
| 546 | private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { |
| 547 | in.defaultReadObject(); |
| 548 | // Reject streams whose cached hashCode does not match the canonical hash of the deserialized minimum/maximum: a crafted stream cannot supply a forged |
| 549 | // value. |
| 550 | if (hashCode != hash(minimum, maximum)) { |
| 551 | throw new InvalidObjectException("Range hashCode does not match minimum/maximum."); |
| 552 | } |
| 553 | SerializationUtils.requireNonNull(maximum, "maximum null"); |
| 554 | SerializationUtils.requireNonNull(minimum, "minimum null"); |
| 555 | SerializationUtils.requireNonNull(comparator, "comparator null"); |
| 556 | if (comparator.compare(minimum, maximum) > 0) { |
| 557 | throw new InvalidObjectException("Range minimum is greater than maximum under the comparator."); |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | /** |
| 562 | * Gets the range as a {@link String}. |
no test coverage detected