Skip to content
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

CachingClientConnectionFactory NPE [INT-3652] #7612

Closed
spring-operator opened this issue Feb 19, 2015 · 6 comments
Closed

CachingClientConnectionFactory NPE [INT-3652] #7612

spring-operator opened this issue Feb 19, 2015 · 6 comments

Comments

@spring-operator
Copy link
Contributor

Gary Russell opened INT-3652 and commented

When a CCCF is used with no listener and an exception occurs on a socket, an error message is sent to the onMessage method, which expects there to be a listener.

The reader thread will get an NPE.

This was a regression caused by the addition of the ErrorMessage handling.


Affects: 4.0.6, 4.1.2

Referenced from: pull request #1380

Backported to: 4.0.7

1 votes, 2 watchers

@spring-operator
Copy link
Contributor Author

Sergey Shcherbakov commented

There looks to be another scenario where the fix in PR would not be sufficient.
I'm using the CachingClientConnectionFactory with tcp-outbound-channel-adapter in "write-only" mode.
That is I do not expect anything to be read back from the connection.

Nevertheless, since the singleUse is always "on" on the TcpNetConnections comping out from the wrapped TCP connection factory, the reading loop starts here:
https://github.com/spring-projects/spring-integration/blob/master/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNetConnection.java#L140

Since there is always a listener and singleUse is set to true.
So the tcp-outbound-channel-adapter with CachingClientConnectionFactory is listening unnecessarily for the incoming messages.
If the connection is terminated on the other side the handleReadException() is called here:
https://github.com/spring-projects/spring-integration/blob/master/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNetConnection.java#L157

an results in lots of ERROR level messages in the logs.

@spring-operator
Copy link
Contributor Author

Gary Russell commented

Yes; I think it's time to bite the bullet and get rid of this funky "self-closing" connection stuff (have the adapter(s) do the close). I'll open another JIRA issue.

@spring-operator
Copy link
Contributor Author

Gary Russell commented

Although that's unrelated to your unnecessary logs issue - I think we can simply not register the cache as a listener if the cache itself doesn't have a listener.

@spring-operator
Copy link
Contributor Author

Gary Russell commented

Reopening to remove the listener altogether.

@spring-operator
Copy link
Contributor Author

spring-operator commented Feb 23, 2015

Gary Russell commented

After further review; the correct does indeed require #7614 because the cache relies on the self-closing behavior to return the connection by being aware that the interceptor wrapped the connection.

@spring-operator
Copy link
Contributor Author

Gary Russell commented

4.1.3 and 4.0.7 are now available.

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

No branches or pull requests

2 participants