On Tue, 14 Sep 2021 10:14:45 GMT, Masanori Yano <my...@openjdk.org> wrote:

>> test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java line 29:
>> 
>>> 27:  * @summary Potential leak file descriptor for SCTP
>>> 28:  * @requires (os.family == "linux")
>>> 29:  * @run main CloseDescriptors
>> 
>> The test SctpMultiChannel/CloseDescriptors seems to work - at least it 
>> doesn't fail all the time - but it's using `@run main/othervm`. I believe 
>> you should make this test run in /othervm mode for more stability. I will 
>> test again with your later change and /othervm mode.
>
> I pushed a fix to run the test in othervm mode. Please test again.

Meanwhile I did some experiment and was puzzled by the fact that the new test 
still failed intermittently - while the corresponding 
SctpMultiChannel/CloseDescriptors did not. By comparing the two I noticed that 
the SctpMultiChannel test is introducing some delays at key places. I did the 
same to the new test - and behold! It stopped failing.

Here are my changes (ignore the /othervm which you already did):


diff --git a/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java 
b/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java
index 99f9563e016..11e2e52f577 100644
--- a/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java
+++ b/test/jdk/com/sun/nio/sctp/SctpChannel/CloseDescriptors.java
@@ -26,7 +26,7 @@
  * @bug 8238274
  * @summary Potential leak file descriptor for SCTP
  * @requires (os.family == "linux")
- * @run main CloseDescriptors
+ * @run main/othervm CloseDescriptors
  */
 
 import java.io.BufferedReader;
@@ -79,9 +79,12 @@ public class CloseDescriptors {
             selThread = new SelectorThread();
             selThread.start();
 
+            // give time for the server and selector to start
+            Thread.sleep(100);
             for (int i = 0 ; i < 100 ; ++i) {
                 System.out.println(i);
                 doIt(port);
+                Thread.sleep(100);
             }
             System.out.println("end");
             if (!check()) {
@@ -110,6 +113,7 @@ public class CloseDescriptors {
             catch (Exception ex) {
                 ex.printStackTrace();
             }
+            Thread.sleep(200);
         }
     }
 
@@ -199,4 +203,3 @@ public class CloseDescriptors {
         }
     }
 }

-------------

PR: https://git.openjdk.java.net/jdk/pull/5274

Reply via email to