Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

Async samples used brittle Thread.sleep() or indefinite CountDownLatch.await(), causing unreliable behavior under slow networks or hanging indefinitely on failures.

Changes:

  • Sample00_UpdateDefaultsAsync.java: Replaced Thread.sleep(10) with CountDownLatch + doFinally() callback, added 30s timeout
  • Sample06_GetAnalyzerAsync.java: Added 10s timeout to existing CountDownLatch.await()

Both samples now use deterministic synchronization with timeout handling:

CountDownLatch latch = new CountDownLatch(1);

client.getDefaults()
    .doFinally(signalType -> latch.countDown())
    .subscribe(/* ... */);

if (!latch.await(30, TimeUnit.SECONDS)) {
    System.err.println("Operation timed out");
    System.exit(1);
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: changjian-wang <15209050+changjian-wang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add initial release of Azure Content Understanding Java SDK Fix async sample synchronization patterns with timeouts Feb 10, 2026
Copilot AI requested a review from changjian-wang February 10, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants