[CXF-7109] ClientCallback may be invoked twice when Async HTTP Transport is used #187
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/CXF-7109
https://issues.jboss.org/browse/ENTESB-6136
I think the best way to make a client callback invoked once and only once is to remove from the exchange immediately after its
handle***()method is invoked once. It should prevent a client callback from being called more than once not only for the CXF-7109 case but also for any other potential cases where the callback may be invoked more than once accidentally.I added
remove(Class<T>)toExchange(StringMap) for convenience and symmetry. It is necessary to remove the callback right before calling itshandle***(), as otherwise some other thread may grab it concurrently before the current thread invokeshandle***().I also added a test case
AsyncHTTPConduitTest#testCallAsyncCallbackInvokedOnlyOnce(), but please note this test fails only on RHEL 6.8 even without this fix. In order to check if this fix is really effective, you need to run the test on RHEL 6.8 to compare the results.