JAVA 4.9 driver-sync driver - Exception in thread "BufferPoolPruner-1-thread-1" java.lang.IllegalMonitorStateException

Super simple Java code that connects to Atlas cluster, queries a collection displays info then closes. It works, BUT after closing via mongoclient.close() , the program is finished and the JVM exits and throws errors about threads unable to terminate. Happens with all drivers tested (4.9 and all the way down to 3.12).

ONLY happens when doing a query on a collection, if getting properties like the estimatedDcoumentCount, it does not happen. This seems to indicate that its the other clustermates threads that are not terminating on mongoclient.close()

I cant determine how to connect to only the primary cluster - readPreferece=“Primary” has no effect (in code below)

` public class JavaAgent extends AgentBase {
` 
`     public void NotesMain() {
`         
`         try {
`             Session session = getSession();
`             AgentContext agentContext = session.getAgentContext();
` 
`             
`             String DB_USERNAME="username"; 
`             String DB_PASSWORD="pw";
`             String DB_HOST_PROD="host";
`             String DB_DATABASE="db";
` 
`             
`             ConnectionString connectionString = new ConnectionString("mongodb+srv://"+DB_USERNAME+":"+DB_PASSWORD+DB_HOST+"/?readPreference=Primary&retryWrites=true&w=majority");
`             MongoClientSettings settings = MongoClientSettings.builder()
`                     .applyConnectionString(connectionString)
`                     .serverApi(ServerApi.builder()
`                         .version(ServerApiVersion.V1)
'                    
`                         .build())
`                     .build();
`             MongoClient mongoClient = MongoClients.create(settings);
`             MongoDatabase database = mongoClient.getDatabase(DB_DATABASE);
`             MongoCollection<Document> collection = database.getCollection("users");
` 
`             Document query = new Document("_id", new ObjectId("*******SOMEID******"));
`             Document result = collection.find(query).iterator().next();
`             System.out.println("Firstname: "+result.getString("first_name"));
`     
`             System.out.println("The count is:");
`             System.out.println(collection.estimatedDocumentCount());
`             
`             mongoClient.close();
`             
`             
`             
`         } catch(Exception e) {
`             e.printStackTrace();
`         }
`         
`     }
` }

Exception in thread “BufferPoolPruner-1-thread-1” java.lang.IllegalMonitorStateException
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.signal(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Error cleaning up agent threads
Exception in thread “BufferPoolPruner-1-thread-2” java.lang.IllegalMonitorStateException
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.signal(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)