Bill commented on a change in pull request #6930:
URL: https://github.com/apache/geode/pull/6930#discussion_r736006893



##########
File path: 
geode-core/src/test/java/org/apache/geode/internal/net/ByteBufferConcurrencyTest.java
##########
@@ -40,126 +41,145 @@
 @LoopRunnerConfig(count = 100)
 public class ByteBufferConcurrencyTest {
 
-  private BufferPool poolMock;
-
   @Test
-  public void 
concurrentDestructAndOpenCloseShouldReturnToPoolOnce(ParallelExecutor executor)
+  public void concurrentDestructAndOpenCloseShouldReturnToPoolOnce(final 
ParallelExecutor executor)
       throws Exception {
-    poolMock = mock(BufferPool.class);
-    ByteBuffer someBuffer = ByteBuffer.allocate(1);
-    ByteBufferVendor sharing =
+    final BufferPool poolMock = mock(BufferPool.class);
+    final ByteBuffer someBuffer = ByteBuffer.allocate(1);
+    final ByteBufferVendor vendor =
         new ByteBufferVendor(someBuffer, BufferPool.BufferType.TRACKED_SENDER,
             poolMock);
-    executor.inParallel(() -> {
-      sharing.destruct();
-    });
-    executor.inParallel(() -> {
-      try {
-        try (ByteBufferSharing localSharing = sharing.open()) {
-          localSharing.getBuffer();
-        }
+
+    final RunnableWithException useBuffer = () -> {
+      try (final ByteBufferSharing sharing = vendor.open()) {
+        useBuffer(sharing);
       } catch (IOException e) {
-        // It's ok to get an IOException if the sharing was destroyed before 
this runs
+        // It's ok to get an IOException if the sharing was destruct()ed 
before this runs
       }
+    };
+
+    for (int i = 0; i < 10; ++i) {
+      executor.inParallel(useBuffer);
+    }
+    executor.inParallel(() -> {
+      vendor.destruct();
     });
+    for (int i = 0; i < 10; ++i) {
+      executor.inParallel(useBuffer);
+    }
+
     executor.execute();
 
     verify(poolMock, times(1)).releaseBuffer(any(), any());
   }
 
+  private void useBuffer(final ByteBufferSharing sharing) throws IOException {
+    sharing.getBuffer();
+    yield(); //

Review comment:
       sleeping now




-- 
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]


Reply via email to