Skip to content

GH-8609: Fix bug that cannot applied correctly TcpConnectorInterceptor #8610

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 1 commit into from
May 5, 2023

Conversation

kazuki43zoo
Copy link
Contributor

@kazuki43zoo kazuki43zoo commented May 4, 2023

Fixes #8609

  • add getLastWrapper() in TcpConnectionSupport
  • change to passed the instance that geted via getLastWrapper() instead of self instance to TcpSender#addNewConnection
  • Changed to passed the self instance to addNewConnection instead of argument's connection

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.

I wonder what is wrong with my suggestion to fix TcpConnectionInterceptorSupport: #8609 (comment).

The test looks OK and I believe the outcome will be exactly the same with my fix.

@kazuki43zoo
Copy link
Contributor Author

kazuki43zoo commented May 4, 2023

The difference is wrapped connection that passed to interceptor's addNewConnection method:

Your change is:

AbstractServerConnectionFactory#initializeConnection
  →  CharacterAppendingInterceptor2#registerSenders(TcpSendingMessageHandler)
        →  CharacterAppendingInterceptor1#registerSenders(CharacterAppendingInterceptor1)
             →  CharacterAppendingInterceptor1#registerSender(CharacterAppendingInterceptor1)
                  →  CharacterAppendingInterceptor1#addNewConnection(CharacterAppendingInterceptor1) ★★Difference★★
                       →  CharacterAppendingInterceptor2#addNewConnection(CharacterAppendingInterceptor1) ★★Difference★★
                            →  TcpSendingMessageHandler#addNewConnection(CharacterAppendingInterceptor2)

My change is:

AbstractServerConnectionFactory#initializeConnection
  →  CharacterAppendingInterceptor2#registerSenders(TcpSendingMessageHandler)
        →  CharacterAppendingInterceptor1#registerSenders(CharacterAppendingInterceptor1)
             →  CharacterAppendingInterceptor1#registerSender(CharacterAppendingInterceptor1)
                  →  CharacterAppendingInterceptor1#addNewConnection(CharacterAppendingInterceptor2) ★★Difference★★
                       →  CharacterAppendingInterceptor2#addNewConnection(CharacterAppendingInterceptor2) ★★Difference★★
                            →  TcpSendingMessageHandler#addNewConnection(CharacterAppendingInterceptor2)

I thought it would be better to pass the last wrapped connection to all interceptors, what do you think?

@artembilan
Copy link
Member

Yeah... It would be better to not have any wrapping at all, but rather just a chain of interceptors injected into a Connection.
But that's fully different story.

Let's listener what @garyrussell has in his mind on the matter!
He is an author of this TCP/IP framework, so better to make the final decision counting on his opinion.

Thank you for the contribution anyway!

@garyrussell
Copy link
Contributor

I thought it would be better to pass the last wrapped connection to all interceptors, what do you think?

My intuition is that an interceptor in the chain should only reference the next in the chain, not the outermost one.

So I prefer @artembilan 's approach.

@kazuki43zoo
Copy link
Contributor Author

@garyrussell @artembilan
Thanks for your comment!! I will change the code by @artembilan 's approach!!

…ectorInterceptor

Fixes spring-projects#8609

* Changed to passed the self instance to addNewConnection instead of argument's connection
@kazuki43zoo
Copy link
Contributor Author

@garyrussell @artembilan
I've changed the code by @artembilan 's approach, please review again when you have time! Thanks!

@kazuki43zoo kazuki43zoo requested a review from artembilan May 4, 2023 21:44
@artembilan artembilan merged commit 9e7b20a into spring-projects:main May 5, 2023
@artembilan
Copy link
Member

... and cherry-picked to 6.0.x & 5.5.x.

@kazuki43zoo ,
thank you for contribution; looking forward for more!

@kazuki43zoo kazuki43zoo deleted the GH-8609 branch May 5, 2023 13:38
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.

Cannot applied correctly TcpConnectorInterceptor on sending with server connection
3 participants