mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
junit: blocking read replaces another pair of sockets
This commit is contained in:
@@ -40,7 +40,7 @@ import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
@@ -189,19 +189,12 @@ public class TestPackage extends TestObject {
|
||||
final boolean[] isJunit4 = new boolean[1];
|
||||
final Task.Backgroundable task =
|
||||
new Task.Backgroundable(classFilter.getProject(), ExecutionBundle.message("seaching.test.progress.title"), true) {
|
||||
int myPort = -1;
|
||||
private Socket mySocket;
|
||||
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
final Socket socket = serverSocket.accept();
|
||||
final DataInputStream is = new DataInputStream(socket.getInputStream());
|
||||
try {
|
||||
myPort = is.readInt();
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
mySocket = serverSocket.accept();
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
@@ -226,16 +219,17 @@ public class TestPackage extends TestObject {
|
||||
}
|
||||
|
||||
private void connect() {
|
||||
Socket socket = null;
|
||||
DataOutputStream os = null;
|
||||
try {
|
||||
socket = new Socket(InetAddress.getLocalHost(), myPort);
|
||||
os = new DataOutputStream(mySocket.getOutputStream());
|
||||
os.writeBoolean(true);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (socket != null) socket.close();
|
||||
if (os != null) os.close();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.info(e);
|
||||
|
||||
@@ -98,19 +98,12 @@ public class JUnitStarter {
|
||||
final int port = Integer.parseInt(arg.substring(SOCKET.length()));
|
||||
try {
|
||||
final Socket socket = new Socket(InetAddress.getLocalHost(), port); //start collecting tests
|
||||
final ServerSocket serverSocket = new ServerSocket(0);
|
||||
final DataInputStream os = new DataInputStream(socket.getInputStream());
|
||||
try {
|
||||
final DataOutputStream os = new DataOutputStream(socket.getOutputStream());
|
||||
try {
|
||||
os.writeInt(serverSocket.getLocalPort()); //write port to sync
|
||||
}
|
||||
finally {
|
||||
os.close();
|
||||
}
|
||||
serverSocket.accept();
|
||||
os.readBoolean();//wait for ready flag
|
||||
}
|
||||
finally {
|
||||
serverSocket.close();
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user