Conversation
…connectors in UseCase3 tests testBatchUseCase3Failure asserted zero results right after executeBatch(), but the UseCase3 test connector delivers results from its own thread, so the first onNext() could already have run. Drop the transient checks and wait up to 3 s for hasError instead of a fixed 500 ms sleep, as OpenIdentityPlatform#93 did for testBatchUseCase3. Both UseCase3 tests now close their subscriptions: each one holds a pooled connector until it is closed, so repeated runs exhausted the pool and hung in borrowObject(). Closing the queryBatch subscription of a finished batch threw an NPE, because SubscriptionImpl wrapped the null subscription returned by the connector. Make close() and isUnsubscribed() of the executeBatch and queryBatch wrappers null-safe, as getReturnValue() of queryBatch already was. Fixes OpenIdentityPlatform#151
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #151
Problem
LocalConnectorInfoManagerTests.testBatchUseCase3Failurechecked that there were no results right afterexecuteBatch(). The UseCase3 test connector delivers results to the observer from its own thread, so the firstonNext()can run before that check. Stress-running the test 300 times on master gave 6 failures withexpected [0] but found [1], the error reported in #151.Fixing it turned up two more problems:
SubscriptionthatexecuteBatch()/queryBatch()return holds a pooled connector until it is closed. The tests never closed theirs. A single run hides this, but repeated runs exhaust the pool and hang inObjectPool.borrowObject().nullfromqueryBatch();TstConnectordoes.SubscriptionImplwraps thatnull. ItsgetReturnValue()already handlednull, butclose()andisUnsubscribed()threw an NPE.Change
LocalConnectorInfoManagerTests:testBatchUseCase3Failureno longer checks the transient state. It waits up to 3 s forhasErrorinstead of a fixedThread.sleep(500), the same approach Stabilizerelease-mavenby removing race-prone assertion intestBatchUseCase3#93 took fortestBatchUseCase3.hasErroris set after the result is added to the list, so both results are in place when the wait ends.finally.testBatchUseCase3keeps thequeryBatch()subscription in its own variable instead of overwriting theexecuteBatch()one.SubscriptionImpl:executeBatch()andqueryBatch()wrappers,close()andisUnsubscribed()now accept anullsubscription. So doesgetReturnValue()ofexecuteBatch().doRelease()still runs first, so the reference counter is always released.Contrary to what #151 says,
testBatchUseCase2andtestBatchUseCase2Failureare not affected. In UseCase2 the results reach the observer only throughqueryBatch(), which the test thread itself calls.Testing
testBatchUseCase3andtestBatchUseCase3Failure: 600/600 pass in 65 s, with no hang.connector-framework(197),connector-test-common(5),connector-framework-internal(509, 2 skipped as before),connector-framework-rpc(21) andconnector-framework-server(32).