Skip to content

GH-2759: Fix CorrelationData.future #2761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 22, 2019

Conversation

garyrussell
Copy link
Contributor

Fixes #2759

The outbound endpoints wrap user correlation data in a wrapper.
If the user data is a CorrelationData, we must delegate methods
involving the Future<?> and returnedMessage to the user data.

cherry-pick to 2.1 and switch AMQP to snapshots

Fixes spring-projects#2759

The outbound endpoints wrap user correlation data in a wrapper.
If the user data is a `CorrelationData`, we must delegate methods
involving the `Future<?>` and `returnedMessage` to the user data.

**cherry-pick to 2.1 and switch AMQP to snapshots**
Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one concern, but I think it is critical...


@Override
public org.springframework.amqp.core.Message getReturnedMessage() {
return super.getReturnedMessage();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you are missing here something: since you delegate to the userData in the setReturnedMessage(), I guess you need to do the same here as well.
Otherwise this override just doesn't make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, in the setter I call super too; but you are correct, this should be removed.

this.correlationDataGenerator.processMessage(requestMessage), requestMessage);
Object userData = this.correlationDataGenerator.processMessage(requestMessage);
if (userData != null) {
correlationData = new CorrelationDataWrapper(messageId.toString(), userData, requestMessage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like previously we have had a CorrelationDataWrapper instance independently of the userData, but now you restrict it only if that one is not null.

Also I see that you are protected against null in the CorrelationDataWrapper any way.

So, what is the motivation to not do that any more?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we get an NPE in handleConfirm() if the expression resolves to null (bug - try to create a message with a null payload).

I should have mentioned it in the commit comment and, I suppose, this part should be back-ported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we emit WARN then in case of correlationDataGenerator resolves to null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to go with DEBUG (there is a corresponding DEBUG in handleConfirm).

Someone might want to use this as a feature ("I don't care about a confirm for this message").

@artembilan artembilan merged commit d6ac866 into spring-projects:master Feb 22, 2019
@artembilan
Copy link
Member

Cherry-picked to 5.1.x as cb1b1c8 after fixing conflicts.

Do we need to back-port further down to 4.3.x? At least some part of your change, e.g. that NPE protection

@garyrussell
Copy link
Contributor Author

Yes, but just the NPE protection - the future was added in S-A 2.1.

I can create a new PR if you prefer.

@artembilan
Copy link
Member

I'm OK to back-port that part.

Thanks for confirmation!

artembilan added a commit that referenced this pull request Feb 22, 2019
**Cherry-pick to 4.3.x**

Related to #2761
artembilan added a commit that referenced this pull request Feb 22, 2019
**Cherry-pick to 4.3.x**

Related to #2761

# Conflicts:
#	spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AbstractAmqpOutboundEndpoint.java
@artembilan
Copy link
Member

Back-ported NPE fix to 5.0.x as 8f1a1c1 and cherry-picked to 4.3.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants