eric-wang-1990 opened a new pull request, #3715: URL: https://github.com/apache/arrow-adbc/pull/3715
## Summary - Changed token exchange from non-blocking to blocking synchronous operation - Fixed concurrent token exchange handling for multiple different tokens - Ensures requests use the exchanged Databricks token instead of the original token that would fail authentication - Simplified implementation with proper concurrent request handling ## Problem The previous non-blocking implementation had two issues: 1. **First request would fail**: The handler would send the first request with the original non-Databricks token (e.g., Azure AD, AWS IAM) while starting token exchange in the background. Since this is **mandatory** token exchange, the non-Databricks token would fail authentication with Databricks. 2. **Different tokens not handled correctly**: When multiple requests came in with different tokens, the second token would not be exchanged properly if it arrived during the first token's exchange. ## Solution - Token exchange now blocks the request until completion using direct `await` instead of `Task.Run` - Added `_tokenBeingExchanged` field to track which token is currently being exchanged - Serialize token exchanges: when a different token arrives during an ongoing exchange, wait for completion then start new exchange - Removed `_pendingTokenTask` field and associated tracking logic - Removed `Dispose` method (no longer needed without background tasks) - Removed `_lastSeenToken` check from `NeedsTokenExchange` to avoid race conditions - Falls back to original token if exchange fails, with improved error message - Single-token cache prevents unbounded memory growth ## Test plan - [x] Test with external token to verify exchange blocks until completion before first request - [x] Verify subsequent requests reuse the cached exchanged token - [x] Test with different external tokens to verify each is exchanged properly - [x] Test concurrent requests with same token verify only one exchange happens - [x] Test token exchange failure scenario to confirm fallback behavior - [x] Verify all 11 unit tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
