We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 071085c commit 72eff29Copy full SHA for 72eff29
core/src/test/java/com/google/cloud/sql/core/MonitoredCacheTest.java
@@ -71,7 +71,13 @@ public void testMonitoredCachePurgesClosedSockets() throws InterruptedException
71
cache.addSocket(socket);
72
Assert.assertEquals("1 socket in cache", 1, cache.getOpenSocketCount());
73
socket.close();
74
- Thread.sleep(20);
+
75
+ // Wait for the MonitoredCache task to clean up the socket, up to 500ms.
76
+ for (int i = 0; cache.getOpenSocketCount() > 0 && i < 10; i++) {
77
+ Thread.sleep(50);
78
+ }
79
80
+ // Ensure that the socket was removed from the cache.
81
Assert.assertEquals("0 socket in cache", 0, cache.getOpenSocketCount());
82
}
83
0 commit comments