Skip to content

Flaky testAsynchronousBatch: pre-handshake operation response is dropped, executeBatch hangs until "Operation finished on remote server with unknown result" #107

Closed

Description

@vharseko

Symptom

AsyncRemoteSecureConnectorInfoManagerTest.testAsynchronousBatch intermittently fails in CI (windows-latest, Java 26) after exactly 540 s:

org.identityconnectors.framework.common.exceptions.ConnectorException: Operation finished on remote server with unknown result
	at org.forgerock.openicf.framework.remote.rpc.RemoteOperationRequest.check(RemoteOperationRequest.java:70)
	at org.forgerock.openicf.framework.remote.rpc.WebSocketConnectionGroup.checkIsActive(WebSocketConnectionGroup.java:353)
	at org.forgerock.openicf.framework.client.ConnectionManager$2.run(ConnectionManager.java:141)

Example run: https://github.com/OpenIdentityPlatform/OpenICF/actions/runs/29724340797/job/88293965805

This still reproduces after #105, which fixed a different race (CompletionListener.start() double-start).

Root cause

The job log shows the full chain:

  1. OpenICFServerAdapter.onMessage dispatches every WebSocket message to a cached thread pool (ConnectorFramework.messageExecutor), so two messages delivered in order on the same socket can be processed out of order. On a freshly opened socket the server's batch-token operation response overtook the handshake response:
    07:27:28.990  Client received response('2') before handshake via socket:916,147,150
    07:27:29.019  Client accept Handshake (C6E44631...:916,147,150)
    
    The pre-handshake branch of handleResponseMessage silently discards the response (only bounces an error to the peer), so the batch token was lost.
  2. All task results and the "complete" message arrived on other sockets, so BatchApiOpImpl$InternalRequest.CompletionListener started waiting, timed out 5 s later with returnToken == null:
    07:27:29.078  CompletionListener waiting for final result to complete.
    07:27:34.118  Batch CompletionListener timed out. Unable to return batch token.
    
    and exited without completing the promise, leaving the caller blocked forever in promise.getOrThrowUninterruptibly() inside executeBatch().
  3. The client's connection group checker (runs at 1 min, then every 4 min) collected 3 inconsistent() strikes from the peer's ControlRequests (the server had long finished the request) and failed the operation at the 9-minute mark — hence exactly 540 s elapsed.

Proposed fix

  • OpenICFServerAdapter.processMessage: before dispatching a non-handshake message on a socket that is not yet handhooked, briefly wait for the concurrently-processing handshake to complete instead of discarding the message (falls back to the current behavior if no handshake arrives).
  • BatchApiOpImpl.CompletionListener: when the wait times out with no batch token, fail the promise with a ConnectorException instead of returning silently, so a lost token surfaces as an error in seconds instead of a 9-minute hang.

Activity

  1. added
    bug
    framework
    on Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugframework

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions