rootvector2 commented on code in PR #682:
URL:
https://github.com/apache/commons-collections/pull/682#discussion_r3419447631
##########
src/main/java/org/apache/commons/collections4/map/PredicatedMap.java:
##########
@@ -155,6 +156,11 @@ public void putAll(final Map<? extends K, ? extends V>
mapToCopy) {
private void readObject(final ObjectInputStream in) throws IOException,
ClassNotFoundException {
in.defaultReadObject();
map = (Map<K, V>) in.readObject(); // (1)
+ try {
+ map.forEach(this::validate);
+ } catch (final IllegalArgumentException ex) {
+ throw new InvalidObjectException(ex.getMessage());
Review Comment:
done, kept the cause with `initCause(ex)` on the `InvalidObjectException`.
##########
src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java:
##########
@@ -409,6 +412,22 @@ public boolean addAll(final Collection<? extends E> coll) {
return decorated().addAll(coll);
}
+ /**
+ * Deserializes the collection in using a custom routine.
+ *
+ * @param in the input stream
+ * @throws IOException if an error occurs while reading from the stream
+ * @throws ClassNotFoundException if an object read from the stream cannot
be loaded
+ */
+ private void readObject(final ObjectInputStream in) throws IOException,
ClassNotFoundException {
+ in.defaultReadObject();
+ try {
+ decorated().forEach(this::validate);
+ } catch (final IllegalArgumentException ex) {
+ throw new InvalidObjectException(ex.getMessage());
Review Comment:
fixed, it chains the original `IllegalArgumentException` through `initCause`
now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]