File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
org.eclipse.lsp4j.jsonrpc/src/test/java/org/eclipse/lsp4j/jsonrpc/test Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,8 @@ public void testCancellation() throws Exception {
101101
102102 in .connect (out2 );
103103 out .connect (in2 );
104-
104+
105+ boolean [] inComputeAsync = new boolean [1 ];
105106 boolean [] cancellationHappened = new boolean [1 ];
106107
107108 MyClient client = new MyClient () {
@@ -110,6 +111,7 @@ public CompletableFuture<MyParam> askClient(MyParam param) {
110111 return CompletableFutures .computeAsync (cancelToken -> {
111112 try {
112113 long startTime = System .currentTimeMillis ();
114+ inComputeAsync [0 ] = true ;
113115 do {
114116 cancelToken .checkCanceled ();
115117 Thread .sleep (50 );
@@ -138,8 +140,16 @@ public CompletableFuture<MyParam> askServer(MyParam param) {
138140 serverSideLauncher .startListening ();
139141
140142 CompletableFuture <MyParam > future = serverSideLauncher .getRemoteProxy ().askClient (new MyParam ("FOO" ));
141- future . cancel ( true );
143+
142144 long startTime = System .currentTimeMillis ();
145+ while (!inComputeAsync [0 ]) {
146+ Thread .sleep (50 );
147+ if (System .currentTimeMillis () - startTime > TIMEOUT )
148+ Assert .fail ("Timeout waiting for client to start computing." );
149+ }
150+ future .cancel (true );
151+
152+ startTime = System .currentTimeMillis ();
143153 while (!cancellationHappened [0 ]) {
144154 Thread .sleep (50 );
145155 if (System .currentTimeMillis () - startTime > TIMEOUT )
You can’t perform that action at this time.
0 commit comments