提交 30b81bf7 编写于 作者: E egahlin

6402201: ProcessAttachTest.sh needs better synchronization

Reviewed-by: alanb
上级 03ce6212
...@@ -304,9 +304,6 @@ com/sun/jdi/SuspendThreadTest.java generic-all ...@@ -304,9 +304,6 @@ com/sun/jdi/SuspendThreadTest.java generic-all
# Filed 6653793 # Filed 6653793
com/sun/jdi/RedefineCrossEvent.java generic-all com/sun/jdi/RedefineCrossEvent.java generic-all
# Filed 6402201
com/sun/jdi/ProcessAttachTest.sh generic-all
############################################################################ ############################################################################
# jdk_util # jdk_util
......
/* /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
*/ */
import java.net.Socket; import java.net.Socket;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
...@@ -39,10 +42,12 @@ public class ProcessAttachDebuggee { ...@@ -39,10 +42,12 @@ public class ProcessAttachDebuggee {
int port = ss.getLocalPort(); int port = ss.getLocalPort();
// Write the port number to the given file // Write the port number to the given file
File f = new File(args[0]); File partial = new File(args[0] + ".partial");
FileOutputStream fos = new FileOutputStream(f); File portFile = new File(args[0]);
try (FileOutputStream fos = new FileOutputStream(partial)) {
fos.write( Integer.toString(port).getBytes("UTF-8") ); fos.write( Integer.toString(port).getBytes("UTF-8") );
fos.close(); }
Files.move(partial.toPath(), portFile.toPath(), StandardCopyOption.ATOMIC_MOVE);
System.out.println("Debuggee bound to port: " + port); System.out.println("Debuggee bound to port: " + port);
System.out.flush(); System.out.flush();
......
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -158,7 +158,17 @@ $JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ ...@@ -158,7 +158,17 @@ $JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \
# The debuggee is suspended and doesn't run until the debugger # The debuggee is suspended and doesn't run until the debugger
# disconnects. We have to give it time to write the port number # disconnects. We have to give it time to write the port number
# to ${PORTFILE} # to ${PORTFILE}
sleep 10
echo "Waiting for port file to be written..."
attempts=0
while true; do
sleep 1
attempts=`expr $attempts + 1`
if [ -f ${PORTFILE} ]; then
break
fi
echo "Waiting $attempts second(s) ..."
done
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
stopDebuggee "${PORTFILE}" stopDebuggee "${PORTFILE}"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册