{"action":"created","comment":{"url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments/31858350","id":31858350,"diff_hunk":"@@ -253,13 +260,33 @@ public void registerListener(TcpListener listener) {\n \t\t// Determine the actual listener for this connection\n \t\tif (!(this.listener instanceof TcpConnectionInterceptor)) {\n \t\t\tthis.actualListener = this.listener;\n-\t\t} else {\n+\t\t}\n+\t\telse {\n \t\t\tTcpConnectionInterceptor outerInterceptor = (TcpConnectionInterceptor) this.listener;\n \t\t\twhile (outerInterceptor.getListener() instanceof TcpConnectionInterceptor) {\n \t\t\t\touterInterceptor = (TcpConnectionInterceptor) outerInterceptor.getListener();\n \t\t\t}\n \t\t\tthis.actualListener = outerInterceptor.getListener();\n \t\t}\n+\t\tthis.listenerRegisteredLatch.countDown();\n+\t}\n+\n+\t/**\n+\t * Set whether or not automatic or manual registratiom of the {@link TcpListener} is to be\n+\t * used. (Default automatic). When manual registration is in place, incoming messages will\n+\t * be delayed until the listener is registered.\n+\t * @since 1.4.5\n+\t */\n+\tpublic void enableManualListenerRegistration() {\n+\t\tthis.manualListenerRegistration = true;\n+\t\tthis.listener = new TcpListener() {","path":"spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionSupport.java","position":84,"original_position":84,"commit_id":"4a0809432b435f69fd72592407c2688d077f155f","original_commit_id":"4a0809432b435f69fd72592407c2688d077f155f","user":{"login":"garyrussell","id":483832,"avatar_url":"https://avatars.githubusercontent.com/u/483832?v=3","gravatar_id":"","url":"https://api.github.com/users/garyrussell","html_url":"https://github.com/garyrussell","followers_url":"https://api.github.com/users/garyrussell/followers","following_url":"https://api.github.com/users/garyrussell/following{/other_user}","gists_url":"https://api.github.com/users/garyrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/garyrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garyrussell/subscriptions","organizations_url":"https://api.github.com/users/garyrussell/orgs","repos_url":"https://api.github.com/users/garyrussell/repos","events_url":"https://api.github.com/users/garyrussell/events{/privacy}","received_events_url":"https://api.github.com/users/garyrussell/received_events","type":"User","site_admin":false},"body":"Yes, I thought about that after realizing it was used at runtime via `getListener()`, but I decided to leave it in case someone ever accesses the field directly.","created_at":"2015-06-05T22:56:00Z","updated_at":"2015-06-05T22:56:00Z","html_url":"https://github.com/spring-projects/spring-integration/pull/1458#discussion_r31858350","pull_request_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1458","_links":{"self":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments/31858350"},"html":{"href":"https://github.com/spring-projects/spring-integration/pull/1458#discussion_r31858350"},"pull_request":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1458"}}},"pull_request":{"url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1458","id":37070555,"html_url":"https://github.com/spring-projects/spring-integration/pull/1458","diff_url":"https://github.com/spring-projects/spring-integration/pull/1458.diff","patch_url":"https://github.com/spring-projects/spring-integration/pull/1458.patch","issue_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/1458","number":1458,"state":"open","locked":false,"title":"INT-3728: TCP: Fix Early Receive with Caching CCF","user":{"login":"garyrussell","id":483832,"avatar_url":"https://avatars.githubusercontent.com/u/483832?v=3","gravatar_id":"","url":"https://api.github.com/users/garyrussell","html_url":"https://github.com/garyrussell","followers_url":"https://api.github.com/users/garyrussell/followers","following_url":"https://api.github.com/users/garyrussell/following{/other_user}","gists_url":"https://api.github.com/users/garyrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/garyrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garyrussell/subscriptions","organizations_url":"https://api.github.com/users/garyrussell/orgs","repos_url":"https://api.github.com/users/garyrussell/repos","events_url":"https://api.github.com/users/garyrussell/events{/privacy}","received_events_url":"https://api.github.com/users/garyrussell/received_events","type":"User","site_admin":false},"body":"JIRA: https://jira.spring.io/browse/INT-3728\r\n\r\nThe `CachingClientConnectionFactory` uses a temporary (rejecting) listener until\r\nthe connection is established and then replaces the listener in the connection.\r\n\r\nThere is a race condition in that if the server starts sending messages before the\r\nlistener is replaced, the message is rejected.\r\n\r\nAdd a mechanism to delay `onMessage` calls until the real listener has been\r\nregistered.\r\n\r\nAlso fix `onMessage` in the cached connection so an `ErrorMessage` is propagated correctly.\r\n\r\nTo reproduce: revert src/main; add `Thread.sleep(1000)` before `registerListener(tcpListener);`\r\nin `CachedConnection` ctor and run the new test.\r\n\r\nTo introduce a similar timing hole with the new code, add the sleep before\r\n`this.theConnection.registerListener(this);` in `TcpConnectionInterceptorSupport`.\r\n\r\nSummary of changes:\r\n\r\n`CachingClientConnectionFactory`\r\n- register the underlying connection's listener in the ctor, utilizing the\r\n    `TcpConnectionInterceptorSupport.registerListener()` method.\r\n- fix `ErrorMessage` propagation.\r\n\r\n`AbstractClientConnectionFactory`\r\n- propagate the `enableManualListenerRegistration` to connections.\r\n\r\n`TcpConnectionSuport`\r\n- implement delay when manual listener registration is enabled.\r\n\r\nAdd test case.\r\n\r\n__cherry-pick to 4.1.x__","created_at":"2015-06-05T21:12:06Z","updated_at":"2015-06-05T22:56:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"73513218265ab31888cd02446058d6e64b30a569","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1458/commits","review_comments_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1458/comments","review_comment_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/1458/comments","statuses_url":"https://api.github.com/repos/spring-projects/spring-integration/statuses/4a0809432b435f69fd72592407c2688d077f155f","head":{"label":"garyrussell:INT-3728","ref":"INT-3728","sha":"4a0809432b435f69fd72592407c2688d077f155f","user":{"login":"garyrussell","id":483832,"avatar_url":"https://avatars.githubusercontent.com/u/483832?v=3","gravatar_id":"","url":"https://api.github.com/users/garyrussell","html_url":"https://github.com/garyrussell","followers_url":"https://api.github.com/users/garyrussell/followers","following_url":"https://api.github.com/users/garyrussell/following{/other_user}","gists_url":"https://api.github.com/users/garyrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/garyrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garyrussell/subscriptions","organizations_url":"https://api.github.com/users/garyrussell/orgs","repos_url":"https://api.github.com/users/garyrussell/repos","events_url":"https://api.github.com/users/garyrussell/events{/privacy}","received_events_url":"https://api.github.com/users/garyrussell/received_events","type":"User","site_admin":false},"repo":{"id":2197787,"name":"spring-integration","full_name":"garyrussell/spring-integration","owner":{"login":"garyrussell","id":483832,"avatar_url":"https://avatars.githubusercontent.com/u/483832?v=3","gravatar_id":"","url":"https://api.github.com/users/garyrussell","html_url":"https://github.com/garyrussell","followers_url":"https://api.github.com/users/garyrussell/followers","following_url":"https://api.github.com/users/garyrussell/following{/other_user}","gists_url":"https://api.github.com/users/garyrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/garyrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garyrussell/subscriptions","organizations_url":"https://api.github.com/users/garyrussell/orgs","repos_url":"https://api.github.com/users/garyrussell/repos","events_url":"https://api.github.com/users/garyrussell/events{/privacy}","received_events_url":"https://api.github.com/users/garyrussell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/garyrussell/spring-integration","description":"","fork":true,"url":"https://api.github.com/repos/garyrussell/spring-integration","forks_url":"https://api.github.com/repos/garyrussell/spring-integration/forks","keys_url":"https://api.github.com/repos/garyrussell/spring-integration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/garyrussell/spring-integration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/garyrussell/spring-integration/teams","hooks_url":"https://api.github.com/repos/garyrussell/spring-integration/hooks","issue_events_url":"https://api.github.com/repos/garyrussell/spring-integration/issues/events{/number}","events_url":"https://api.github.com/repos/garyrussell/spring-integration/events","assignees_url":"https://api.github.com/repos/garyrussell/spring-integration/assignees{/user}","branches_url":"https://api.github.com/repos/garyrussell/spring-integration/branches{/branch}","tags_url":"https://api.github.com/repos/garyrussell/spring-integration/tags","blobs_url":"https://api.github.com/repos/garyrussell/spring-integration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/garyrussell/spring-integration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/garyrussell/spring-integration/git/refs{/sha}","trees_url":"https://api.github.com/repos/garyrussell/spring-integration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/garyrussell/spring-integration/statuses/{sha}","languages_url":"https://api.github.com/repos/garyrussell/spring-integration/languages","stargazers_url":"https://api.github.com/repos/garyrussell/spring-integration/stargazers","contributors_url":"https://api.github.com/repos/garyrussell/spring-integration/contributors","subscribers_url":"https://api.github.com/repos/garyrussell/spring-integration/subscribers","subscription_url":"https://api.github.com/repos/garyrussell/spring-integration/subscription","commits_url":"https://api.github.com/repos/garyrussell/spring-integration/commits{/sha}","git_commits_url":"https://api.github.com/repos/garyrussell/spring-integration/git/commits{/sha}","comments_url":"https://api.github.com/repos/garyrussell/spring-integration/comments{/number}","issue_comment_url":"https://api.github.com/repos/garyrussell/spring-integration/issues/comments{/number}","contents_url":"https://api.github.com/repos/garyrussell/spring-integration/contents/{+path}","compare_url":"https://api.github.com/repos/garyrussell/spring-integration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/garyrussell/spring-integration/merges","archive_url":"https://api.github.com/repos/garyrussell/spring-integration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/garyrussell/spring-integration/downloads","issues_url":"https://api.github.com/repos/garyrussell/spring-integration/issues{/number}","pulls_url":"https://api.github.com/repos/garyrussell/spring-integration/pulls{/number}","milestones_url":"https://api.github.com/repos/garyrussell/spring-integration/milestones{/number}","notifications_url":"https://api.github.com/repos/garyrussell/spring-integration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/garyrussell/spring-integration/labels{/name}","releases_url":"https://api.github.com/repos/garyrussell/spring-integration/releases{/id}","created_at":"2011-08-12T15:45:00Z","updated_at":"2015-05-05T14:02:54Z","pushed_at":"2015-06-05T22:47:07Z","git_url":"git://github.com/garyrussell/spring-integration.git","ssh_url":"git@github.com:garyrussell/spring-integration.git","clone_url":"https://github.com/garyrussell/spring-integration.git","svn_url":"https://github.com/garyrussell/spring-integration","homepage":"","size":36357,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"spring-projects:master","ref":"master","sha":"7c785536092cf5965daebb4b2d8152cc6062fa8b","user":{"login":"spring-projects","id":317776,"avatar_url":"https://avatars.githubusercontent.com/u/317776?v=3","gravatar_id":"","url":"https://api.github.com/users/spring-projects","html_url":"https://github.com/spring-projects","followers_url":"https://api.github.com/users/spring-projects/followers","following_url":"https://api.github.com/users/spring-projects/following{/other_user}","gists_url":"https://api.github.com/users/spring-projects/gists{/gist_id}","starred_url":"https://api.github.com/users/spring-projects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spring-projects/subscriptions","organizations_url":"https://api.github.com/users/spring-projects/orgs","repos_url":"https://api.github.com/users/spring-projects/repos","events_url":"https://api.github.com/users/spring-projects/events{/privacy}","received_events_url":"https://api.github.com/users/spring-projects/received_events","type":"Organization","site_admin":false},"repo":{"id":2090979,"name":"spring-integration","full_name":"spring-projects/spring-integration","owner":{"login":"spring-projects","id":317776,"avatar_url":"https://avatars.githubusercontent.com/u/317776?v=3","gravatar_id":"","url":"https://api.github.com/users/spring-projects","html_url":"https://github.com/spring-projects","followers_url":"https://api.github.com/users/spring-projects/followers","following_url":"https://api.github.com/users/spring-projects/following{/other_user}","gists_url":"https://api.github.com/users/spring-projects/gists{/gist_id}","starred_url":"https://api.github.com/users/spring-projects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spring-projects/subscriptions","organizations_url":"https://api.github.com/users/spring-projects/orgs","repos_url":"https://api.github.com/users/spring-projects/repos","events_url":"https://api.github.com/users/spring-projects/events{/privacy}","received_events_url":"https://api.github.com/users/spring-projects/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spring-projects/spring-integration","description":"Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)","fork":false,"url":"https://api.github.com/repos/spring-projects/spring-integration","forks_url":"https://api.github.com/repos/spring-projects/spring-integration/forks","keys_url":"https://api.github.com/repos/spring-projects/spring-integration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spring-projects/spring-integration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spring-projects/spring-integration/teams","hooks_url":"https://api.github.com/repos/spring-projects/spring-integration/hooks","issue_events_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/events{/number}","events_url":"https://api.github.com/repos/spring-projects/spring-integration/events","assignees_url":"https://api.github.com/repos/spring-projects/spring-integration/assignees{/user}","branches_url":"https://api.github.com/repos/spring-projects/spring-integration/branches{/branch}","tags_url":"https://api.github.com/repos/spring-projects/spring-integration/tags","blobs_url":"https://api.github.com/repos/spring-projects/spring-integration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spring-projects/spring-integration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spring-projects/spring-integration/git/refs{/sha}","trees_url":"https://api.github.com/repos/spring-projects/spring-integration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spring-projects/spring-integration/statuses/{sha}","languages_url":"https://api.github.com/repos/spring-projects/spring-integration/languages","stargazers_url":"https://api.github.com/repos/spring-projects/spring-integration/stargazers","contributors_url":"https://api.github.com/repos/spring-projects/spring-integration/contributors","subscribers_url":"https://api.github.com/repos/spring-projects/spring-integration/subscribers","subscription_url":"https://api.github.com/repos/spring-projects/spring-integration/subscription","commits_url":"https://api.github.com/repos/spring-projects/spring-integration/commits{/sha}","git_commits_url":"https://api.github.com/repos/spring-projects/spring-integration/git/commits{/sha}","comments_url":"https://api.github.com/repos/spring-projects/spring-integration/comments{/number}","issue_comment_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/comments{/number}","contents_url":"https://api.github.com/repos/spring-projects/spring-integration/contents/{+path}","compare_url":"https://api.github.com/repos/spring-projects/spring-integration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spring-projects/spring-integration/merges","archive_url":"https://api.github.com/repos/spring-projects/spring-integration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spring-projects/spring-integration/downloads","issues_url":"https://api.github.com/repos/spring-projects/spring-integration/issues{/number}","pulls_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls{/number}","milestones_url":"https://api.github.com/repos/spring-projects/spring-integration/milestones{/number}","notifications_url":"https://api.github.com/repos/spring-projects/spring-integration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spring-projects/spring-integration/labels{/name}","releases_url":"https://api.github.com/repos/spring-projects/spring-integration/releases{/id}","created_at":"2011-07-22T21:47:27Z","updated_at":"2015-06-05T11:46:12Z","pushed_at":"2015-06-05T22:47:35Z","git_url":"git://github.com/spring-projects/spring-integration.git","ssh_url":"git@github.com:spring-projects/spring-integration.git","clone_url":"https://github.com/spring-projects/spring-integration.git","svn_url":"https://github.com/spring-projects/spring-integration","homepage":"http://projects.spring.io/spring-integration/","size":86359,"stargazers_count":355,"watchers_count":355,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":323,"mirror_url":null,"open_issues_count":3,"forks":323,"open_issues":3,"watchers":355,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1458"},"html":{"href":"https://github.com/spring-projects/spring-integration/pull/1458"},"issue":{"href":"https://api.github.com/repos/spring-projects/spring-integration/issues/1458"},"comments":{"href":"https://api.github.com/repos/spring-projects/spring-integration/issues/1458/comments"},"review_comments":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1458/comments"},"review_comment":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1458/commits"},"statuses":{"href":"https://api.github.com/repos/spring-projects/spring-integration/statuses/4a0809432b435f69fd72592407c2688d077f155f"}}}}