Skip to content

Commit f5f839e

Browse files
committed
[GR-66513] Removed conflicting tests that use the same port number and reuse the server address.
PullRequest: graal/21255
2 parents 6d02d43 + 276416a commit f5f839e

File tree

2 files changed

+4
-31
lines changed
  • tools/src

2 files changed

+4
-31
lines changed

tools/src/com.oracle.truffle.tools.dap.test/src/com/oracle/truffle/tools/dap/test/DAPAddressTest.java

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@ public void tearDown() {
5353
output.reset();
5454
}
5555

56-
@Test
57-
public void testHostPortDefault() {
58-
try (Context context = Context.newBuilder().option("dap", "").out(output).build()) {
59-
assert context != null;
60-
}
61-
String[] address = parseSocketAddress(output);
62-
assertAddress("127.0.0.1", "4711", address);
63-
}
64-
6556
@Test
6657
public void testHostPortEnabled() {
6758
try (Context context = Context.newBuilder().option("dap", "true").out(output).build()) {
@@ -80,25 +71,6 @@ public void testHostPortDisabled() {
8071
assertTrue(out, out.isEmpty());
8172
}
8273

83-
@Test
84-
public void testHost() {
85-
Assume.assumeTrue(System.getProperty("os.name").contains("Linux")); // Extra IPs are used
86-
try (Context context = Context.newBuilder().option("dap", "127.0.0.2").out(output).build()) {
87-
assert context != null;
88-
}
89-
String[] address = parseSocketAddress(output);
90-
assertAddress("127.0.0.2", "4711", address);
91-
}
92-
93-
@Test
94-
public void testPort() {
95-
try (Context context = Context.newBuilder().option("dap", "7411").out(output).build()) {
96-
assert context != null;
97-
}
98-
String[] address = parseSocketAddress(output);
99-
assertAddress("127.0.0.1", "7411", address);
100-
}
101-
10274
@Test
10375
public void testBadPorts() {
10476
// Negative
@@ -123,11 +95,11 @@ private void assertBadPort(int p) {
12395
@Test
12496
public void testHostPort() {
12597
Assume.assumeTrue(System.getProperty("os.name").contains("Linux")); // Extra IPs are used
126-
try (Context context = Context.newBuilder().option("dap", "127.0.0.2:7411").out(output).build()) {
98+
try (Context context = Context.newBuilder().option("dap", "127.0.0.2:0").out(output).build()) {
12799
assert context != null;
128100
}
129101
String[] address = parseSocketAddress(output);
130-
assertAddress("127.0.0.2", "7411", address);
102+
assertAddress("127.0.0.2", "?", address);
131103
}
132104

133105
@Test

tools/src/com.oracle.truffle.tools.dap/src/com/oracle/truffle/tools/dap/instrument/DAPInstrument.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -217,6 +217,7 @@ private void launchServer(TruffleInstrument.Env env, PrintWriter info, PrintWrit
217217
final int port = socketAddress.getPort();
218218
final ExecutionContext context = new ExecutionContext(env, info, err, options.get(Internal), options.get(Initialization));
219219
final ServerSocket serverSocket = new ServerSocket(port, options.get(SocketBacklogSize), socketAddress.getAddress());
220+
serverSocket.setReuseAddress(true);
220221
dapServer = DebugProtocolServerImpl.create(context, options.get(Suspend), options.get(WaitAttached), options.get(Initialization), options.get(SourcePath));
221222
dapServer.start(serverSocket).exceptionally(throwable -> {
222223
throwable.printStackTrace(err);

0 commit comments

Comments
 (0)