Skip to content

Commit 5f509ac

Browse files
artembilangaryrussell
authored andcommitted
INT-4394: Fix compatibility with Jackson JSON
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)**
1 parent 51397ec commit 5f509ac

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ subprojects { subproject ->
106106
hibernateVersion = '5.2.10.Final'
107107
hsqldbVersion = '2.4.0'
108108
h2Version = '1.4.196'
109-
jackson2Version = '2.9.1'
109+
jackson2Version = '2.9.4'
110110
javaxActivationVersion = '1.1.1'
111111
javaxMailVersion = '1.6.0'
112112
jedisVersion = '2.9.0'

spring-integration-core/src/main/java/org/springframework/integration/dispatcher/AggregateMessageDeliveryException.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.integration.dispatcher;
1818

19-
import java.util.Collections;
19+
import java.util.ArrayList;
2020
import java.util.List;
2121

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

3941
public AggregateMessageDeliveryException(Message<?> undeliveredMessage,
4042
String description, List<? extends Exception> aggregatedExceptions) {
43+
4144
super(undeliveredMessage, description);
4245
this.initCause(aggregatedExceptions.get(0));
43-
this.aggregatedExceptions = aggregatedExceptions;
46+
this.aggregatedExceptions = new ArrayList<Exception>(aggregatedExceptions);
4447
}
4548

49+
/**
50+
* Obtain a list aggregated target exceptions.
51+
* @return the list of target exceptions
52+
*/
4653
public List<? extends Exception> getAggregatedExceptions() {
47-
return Collections.unmodifiableList(this.aggregatedExceptions);
54+
return new ArrayList<Exception>(this.aggregatedExceptions);
4855
}
4956

5057
@Override

spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupMetadata.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
1717
package org.springframework.integration.store;
1818

1919
import java.io.Serializable;
20-
import java.util.Collections;
2120
import java.util.Iterator;
2221
import java.util.LinkedList;
2322
import java.util.List;
@@ -92,8 +91,13 @@ public UUID firstId() {
9291
return null;
9392
}
9493

94+
/**
95+
* Obtain a {@link LinkedList} copy of the {@link #messageIds}
96+
* stored in the group.
97+
* @return the list of messages ids stored in the group
98+
*/
9599
public List<UUID> getMessageIds() {
96-
return Collections.unmodifiableList(this.messageIds);
100+
return new LinkedList<UUID>(this.messageIds);
97101
}
98102

99103
void complete() {

0 commit comments

Comments
 (0)