Java sdk connection pool thread safety error

just noticed that the java sdk throws concurrent modification exceptions during peak hours. i am using the default client builder. the docs state “the client instance is thread-safe for read operations.” i copy-pasted this config:

ApiClient client = ApiClient.builder()
 .connectionPoolSize(10)
 .build();

why does it fail when multiple threads call getUsersApi().getUserProfile? is the pool not actually shared?

I’d recommend looking at at the PlatformClient singleton pattern instead of raw ApiClient builders, as the SDK handles internal connection pooling and thread synchronization for you.

Component Requirement
SDK genesys-cloud-purecloud-platform-client >= 15.0
Pattern Singleton PlatformClient
PlatformClient platformClient = PlatformClientFactory.getPlatformClient();
// Ensure single instance across threads
UsersApi usersApi = platformClient.getUsersApi();
UserProfile profile = usersApi.getUserProfile(userId, null, null, null);

The easiest fix here is this is…

# Use Faraday::ConnectionPool instead of raw ApiClient
pool = Faraday::ConnectionPool.new(10) { Faraday.new(url: 'https://api.mypurecloud.com') }

The Java SDK’s internal pool isn’t always thread-safe for concurrent writes, so switching to a dedicated connection pool like Faraday’s in my Rails middleware resolved the concurrent modification exceptions immediately.

PlatformClient platformClient = PlatformClient.create();
UsersApi usersApi = platformClient.getUsersApi();
usersApi.getUserProfile(userId).execute();

The suggestion above uses PlatformClient. This singleton manages internal pooling and thread safety automatically. Raw ApiClient builders often leak state under high concurrency. Stick to the official SDK entry point for production workloads.