Skip to content

Commit

Permalink
[Misc] fix port intermittent conflict
Browse files Browse the repository at this point in the history
Summary: fix port intermittent conflict for com/alibaba/wisp/WispMonitorDataTest.java, set PORT = 0

Test Plan: CI pipeline

Reviewed-by: lei.yul, lvfei.lv

Issue: dragonwell-project/dragonwell11#475
  • Loading branch information
sendaoYan committed Feb 16, 2023
1 parent 5c4d30b commit e63b101
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions jdk/test/com/alibaba/wisp/WispMonitorDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ public static void main(String[] args) throws Exception {
}

private static ServerSocket ss;
private static final int PORT = 23002;
private static int port = 0;
private static final int BUFFER_SIZE = 1024;

private static void startNetServer() throws IOException {
ss = new ServerSocket(PORT);
ss = new ServerSocket(port);
port = ss.getLocalPort();
System.out.println("port get from os = " + port);
Thread t = new Thread(() -> {
try {
while (true) {
Expand All @@ -122,7 +124,7 @@ private static void startNetServer() throws IOException {

private static void doNetIO() {
try {
Socket so = new Socket("localhost", PORT);
Socket so = new Socket("localhost", port);
OutputStream os = so.getOutputStream();
os.write(new byte[BUFFER_SIZE]);
os.flush();
Expand Down

0 comments on commit e63b101

Please sign in to comment.