MCPcopy Create free account
hub / github.com/apache/commons-lang / readObject

Method readObject

src/main/java/org/apache/commons/lang3/Range.java:546–559  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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}.

Callers 2

cloneMethod · 0.45
deserializeMethod · 0.45

Calls 3

hashMethod · 0.95
requireNonNullMethod · 0.95
compareMethod · 0.45

Tested by

no test coverage detected