1 #
   2 # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.
   8 #
   9 # This code is distributed in the hope that it will be useful, but WITHOUT
  10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 # version 2 for more details (a copy is included in the LICENSE file that
  13 # accompanied this code).
  14 #
  15 # You should have received a copy of the GNU General Public License version
  16 # 2 along with this work; if not, write to the Free Software Foundation,
  17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 #
  19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 # or visit www.oracle.com if you need additional information or have any
  21 # questions.
  22 #
  23 
  24 #
  25 #  @test
  26 #  @bug 7056731
  27 #  @summary Race condition in CORBA code causes re-use of ABORTed connections
  28 #
  29 #  @run shell 7056731.sh
  30 #
  31 
  32 OS=`uname -s`
  33 case "$OS" in
  34   SunOS | Linux | Darwin | AIX )
  35     PS=":"
  36     FS="/"
  37     ;;
  38   Windows* | CYGWIN* )
  39     PS=";"
  40     FS="\\"
  41     ;;
  42   * )
  43     echo "Unrecognized system!"
  44     exit 1;
  45     ;;
  46 esac
  47 
  48 if [ "${TESTJAVA}" = "" ] ; then
  49   echo "TESTJAVA not set.  Test cannot execute.  Failed."
  50   exit 1
  51 fi
  52 
  53 JAVA="${TESTJAVA}${FS}bin${FS}java"
  54 PORT=1052
  55 cp -r ${TESTSRC}${FS}*.java  ${TESTSRC}${FS}Hello.idl .
  56 echo "Testing...please wait"
  57 
  58 ${COMPILEJAVA}${FS}bin${FS}idlj -fall Hello.idl
  59 ${COMPILEJAVA}${FS}bin${FS}javac *.java HelloApp/*.java
  60 
  61 echo "starting orbd"
  62 ${TESTJAVA}${FS}bin${FS}orbd -ORBInitialPort $PORT -ORBInitialHost localhost &
  63 ORB_PROC=$!
  64 sleep 2 #give orbd time to start
  65 echo "started orb"
  66 echo "starting server"
  67 ${JAVA} ${TESTVMOPTS} -cp . HelloServer -ORBInitialPort $PORT -ORBInitialHost localhost &
  68 SERVER_PROC=$!
  69 sleep 2 #give server time to start
  70 echo "started server"
  71 echo "starting client (debug mode)"
  72 ${JAVA} ${TESTVMOPTS} -cp . -agentlib:jdwp=transport=dt_socket,server=y,address=8000 HelloClient -ORBInitialPort $PORT -ORBInitialHost localhost > client.$$ 2>&1 & 
  73 JVM_PROC=$!
  74 sleep 2 #give jvm/debugger/client time to start
  75 
  76 echo "started client (debug mode)"
  77 echo "starting debugger and issuing commands"
  78 (sleep 2;
  79 echo "stop in com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.unregisterWaiter";
  80 sleep 2;
  81 echo "run";
  82 sleep 2;
  83 echo "cont";
  84 sleep 2;
  85 echo "cont";
  86 sleep 2;
  87 echo "cont";
  88 sleep 2;
  89 echo "suspend 1";
  90 sleep 2;
  91 kill -9 $SERVER_PROC &> /dev/null;
  92 sleep 2;
  93 echo "cont";
  94 sleep 2;
  95 echo "thread 1"
  96 sleep 2;
  97 echo "clear com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.unregisterWaiter"
  98 sleep 2;
  99 echo "resume 1";
 100 )| ${COMPILEJAVA}${FS}bin${FS}jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=8000
 101 
 102 sleep 5 # give time for Client to throw exception
 103 
 104 # JVM_PROC should have exited but just in case, include it.
 105 kill -9 $ORB_PROC $JVM_PROC $SERVER_PROC
 106 
 107 grep "ORBUtilSystemException.writeErrorSend" client.$$
 108 result=$?
 109 if [ $result -eq 0 ]
 110 then
 111     echo "Failed"
 112     exitCode=1;
 113 else 
 114     echo "Passed"
 115     exitCode=0
 116 fi
 117 
 118 #jtreg complaining about not being able to clean up; let's sleep
 119 sleep 2
 120 rm -rf out.$$ client.$$
 121 sleep 2
 122 exit ${exitCode}