Skip to content

Commit

Permalink
INT-4394: Fix compatibility with Jackson JSON
Browse files Browse the repository at this point in the history
JIRA: https://jira.spring.io/browse/INT-4394

Looks like Jackson has became much smarter and now it stores
the target type for the object, not returned interface.

We can't use Jackson annotations on the Framework classes and
we can't restrict the `messagingAwareMapper()` `ObjectMapper` just
to use fields for all the object passed through it.

As a compromise solution we shouldn't use
`Collections.unmodifiableList()` in the getter.
The copy of the internal collection is pretty enough to protect
our object from mutation.

**Cherry-pick to 4.3.x (excluding `build.gradle` change)**

# Conflicts:
#	build.gradle
  • Loading branch information
artembilan committed Feb 5, 2018
1 parent 78d09e1 commit 4f0f3d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@

package org.springframework.integration.dispatcher;

import java.util.Collections;
import java.util.ArrayList;
import java.util.List;

import org.springframework.messaging.Message;
Expand All @@ -28,6 +28,8 @@
* that may try multiple handler invocations within a single dispatch operation.
*
* @author Mark Fisher
* @author Artem Bilan
*
* @since 1.0.3
*/
@SuppressWarnings("serial")
Expand All @@ -38,13 +40,18 @@ public class AggregateMessageDeliveryException extends MessageDeliveryException

public AggregateMessageDeliveryException(Message<?> undeliveredMessage,
String description, List<? extends Exception> aggregatedExceptions) {

super(undeliveredMessage, description);
this.initCause(aggregatedExceptions.get(0));
this.aggregatedExceptions = aggregatedExceptions;
this.aggregatedExceptions = new ArrayList<Exception>(aggregatedExceptions);
}

/**
* Obtain a list aggregated target exceptions.
* @return the list of target exceptions
*/
public List<? extends Exception> getAggregatedExceptions() {
return Collections.unmodifiableList(this.aggregatedExceptions);
return new ArrayList<Exception>(this.aggregatedExceptions);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,6 @@
package org.springframework.integration.store;

import java.io.Serializable;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -92,8 +91,13 @@ public UUID firstId() {
return null;
}

/**
* Obtain a {@link LinkedList} copy of the {@link #messageIds}
* stored in the group.
* @return the list of messages ids stored in the group
*/
public List<UUID> getMessageIds() {
return Collections.unmodifiableList(this.messageIds);
return new LinkedList<UUID>(this.messageIds);
}

void complete() {
Expand Down

0 comments on commit 4f0f3d1

Please sign in to comment.