11/*
2- * Copyright (c) 2018, 2024 SAP SE. All rights reserved.
2+ * Copyright (c) 2018, 2025 SAP SE. 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
@@ -62,6 +62,8 @@ private static int handshake(String path, byte[] handshake, byte[] reply) throws
6262 }
6363 ByteBuffer in = ByteBuffer .wrap (reply );
6464 int result = channel .read (in );
65+ // When we are connected and have received at least one byte, the file should be deleted.
66+ checkSocketDeleted (path );
6567 channel .close ();
6668
6769 return result ;
@@ -97,8 +99,7 @@ public static void main(String[] args) throws Throwable {
9799 try (SocketChannel channel = SocketChannel .open (StandardProtocolFamily .UNIX )) {
98100 // Just see if we can create a unix domain socket on Windows.
99101 } catch (UnsupportedOperationException e ) {
100- System .out .println ("Windows version is too old to support unix domain sockets." );
101- return ;
102+ throw new jtreg .SkippedException ("Windows version is too old to support unix domain sockets." );
102103 }
103104 }
104105
@@ -135,10 +136,9 @@ public static void main(String[] args) throws Throwable {
135136 for (int i = 0 ; i < 3 ; ++i ) {
136137 System .out .println ("Run " + i );
137138 // Wait a bit to let the debugging be set up properly.
138- Thread .sleep (3000 );
139+ Thread .sleep (1000 );
139140 checkSocketPresent (socketName );
140141 read = handshake (socketName , handshake , received );
141- checkSocketDeleted (socketName );
142142 assertEquals (new String (handshake , "UTF-8" ),
143143 new String (received , "UTF-8" ));
144144 assertEquals (read , received .length );
@@ -153,8 +153,16 @@ public static void main(String[] args) throws Throwable {
153153 }
154154 }
155155
156- private static void checkSocketPresent (String name ) {
156+ private static void checkSocketPresent (String name ) throws InterruptedException {
157157 if (!Platform .isWindows ()) {
158+ for (int i = 0 ; i < 10 ; ++i ) {
159+ if (!new File (name ).exists ()) {
160+ Thread .sleep (1000 );
161+ } else {
162+ break ;
163+ }
164+ }
165+
158166 assertTrue (new File (name ).exists (), "Socket " + name + " missing" );
159167 }
160168 }
0 commit comments