Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4793500

TEST_BUG: Regression test NullHost.java fails

XMLWordPrintable

    • generic
    • generic



      Name: asR10013 Date: 12/13/2002


      Filed By : J2SE-SQA [###@###.###
      JDK : JDK1.4.2-b09
      Testbase : RegTest-test
      Falling test[s]:
              java/net/Socket/NullHost.java

      Regression test java/net/Socket/NullHost.java fails from time to time.

      The reason of the failure is that the test closes the server after the first connection:

                      while (true) {
                          s = svr.accept();
                          s.close();
                          svr.close(); // !!!
      }

      The test always fails on our Suse 8 computer (linux-19).
      Due to races the test passes on some platforms (i.e. it passes on my Linux RH 7.2 (linux-12)).
      But after I had modified the code as follows:

          public NullHost () throws IOException {
              Server s = new Server();
              int port = s.getPort();
              s.start();
              try {
                  Socket sock = new Socket((String)null, port);
                  sock.close();

                  try{ Thread.sleep(1000); }catch(Exception e){}; // !!!

                  sock = new Socket((String)null, port, true);
                  sock.close();
                  sock = new Socket((String)null, port, null, 0);
                  sock.close();

      the test failed on my Linux RH 7.2 (linux-12) too.

      svr.close() should be moved outside the loop.

      After I had modified the code of Server.run() as follows:

              public void run() {
                  Socket s;
                  try {
                      while (true) {
                          s = svr.accept();
                          s.close();
                      }
                  } catch (IOException e) {
                  } finally {
                      try{ svr.close(); } catch(Exception e){}
                  }
              }

      the test passes on both Linux RH 7.2 (linux-12) and Suse 8 (linux-19).

      Test source location:
      =====================
      /java/re/jdk/1.4.2/promoted/latest/ws/j2se/test/java/net/Socket/NullHost.java

      jtr file location:
      ==================
      /net/jtgb4u4c.sfbay/export/sail15/results/mantis/b09/regtest/linux/suse8.0_gnome_-client_linux-19/workDir/test/java/net/Socket/NullHost.jtr

      How to reproduce:
      =================
      Run the following script (you may need to change its variables)
       
      --- script start ---
      #!/bin/sh

      RESULT_DIR=`pwd`
      WORK_DIR=$RESULT_DIR/workDir/test
      REPORT_DIR=$RESULT_DIR/reportDir
      JT_HOME="/net/linux-15/export/home/java/jct"
      JAVA_HOME="/net/linux-15/export/home/java/jdk1.4.2/linux"
      TEST_BASE_PATH="/net/linux-15/export/home/java/regtest/test"

      TESTWITH=$JAVA_HOME
      TESTJAVA=$JAVA_HOME

      JTOPTS="-client"
      TESTVMOPTS="-client"

      CLASSPATH="$JT_HOME/classes:$JT_HOME/lib/javatest.jar:$JT_HOME/lib/jtreg.jar"

      export JAVA_HOME
      export JT_HOME
      export TESTWITH
      export CLASSPATH

      mkdir -p $WORK_DIR/scratch 2>&1
      mkdir -p $WORK_DIR/jtData 2>&1
      mkdir -p $REPORT_DIR 2>&1

      #rm $WORK_DIR/jtData/ResultCache.jtw 2>&1

      cd $WORK_DIR/scratch

      $JAVA_HOME/bin/java -cp $CLASSPATH $JTOPTS -DenvVars=TESTJAVAHOME=$JAVA_HOME,TESTVMOPTS=$TESTVMOPTS,DISPLAY=:0,HOME=$HOME/.regtest,PATH=/bin:/usr/bin,TZ=,LC_ALL=en_US,LC_CTYPE=en_US,LANG=en_US,LPDEST= -DDISPLAY=:0 -DlocalHost="linux-19" -Dprogram=jtreg com.sun.javatest.regtest.Main -a -v default -batch -params -w "$WORK_DIR" -r "$REPORT_DIR" -t "$TEST_BASE_PATH" "$TEST_BASE_PATH/java/net/Socket/NullHost.java"

      --- script end ---

      Test output (jtr part):
      =======================
      ----------System.out:(0/0)----------
      ----------System.err:(22/1173)----------
      java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
      at java.net.Socket.connect(Socket.java:452)
      at java.net.Socket.connect(Socket.java:402)
      at java.net.Socket.<init>(Socket.java:309)
      at java.net.Socket.<init>(Socket.java:253)
      at NullHost.<init>(NullHost.java:71)
      at NullHost.main(NullHost.java:61)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:82)
      at java.lang.Thread.run(Thread.java:536)

      JavaTest Message: Test threw exception: java.net.ConnectException: Connection refused
      JavaTest Message: shutting down test

      STATUS:Failed.`main' threw exception: java.net.ConnectException: Connection refused
      result: Failed. Execution failed: `main' threw exception: java.net.ConnectException: Connection refused


      test result: Failed. Execution failed: `main' threw exception: java.net.ConnectException: Connection refused


      Specific machine info:
      ======================
      Hostname: linux-19
      OS: SuSe 8.0 (GNOME)

      ======================================================================

            jccollet Jean-Christophe Collet (Inactive)
            alssunw Als Als (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: