Skip to content

Commit 6d86c99

Browse files
committed
Issue #22 - Using Jetty with Spring Webclient causes thread leak.
Added test case - there appear to be no issue though. Signed-off-by: Simone Bordet <[email protected]>
1 parent c58b25c commit 6d86c99

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/test/java/org/eclipse/jetty/reactive/client/ReactorTest.java

+34
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
package org.eclipse.jetty.reactive.client;
1717

1818
import java.io.IOException;
19+
import java.io.InterruptedIOException;
20+
import java.net.URI;
21+
import java.time.Duration;
1922
import java.util.Random;
2023

2124
import javax.servlet.http.HttpServletRequest;
@@ -27,6 +30,7 @@
2730
import org.testng.Assert;
2831
import org.testng.annotations.Factory;
2932
import org.testng.annotations.Test;
33+
import reactor.core.publisher.Mono;
3034

3135
public class ReactorTest extends AbstractTest {
3236
@Factory(dataProvider = "protocols", dataProviderClass = AbstractTest.class)
@@ -54,4 +58,34 @@ protected void service(String target, Request jettyRequest, HttpServletRequest r
5458
Assert.assertNotNull(responseContent);
5559
Assert.assertEquals(data, responseContent);
5660
}
61+
62+
@Test
63+
public void testTotalTimeout() throws Exception {
64+
long timeout = 1000;
65+
String result = "HELLO";
66+
prepare(new EmptyHandler() {
67+
@Override
68+
protected void service(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
69+
try {
70+
Thread.sleep(2 * timeout);
71+
response.getWriter().write(result);
72+
} catch (InterruptedException x) {
73+
throw new InterruptedIOException();
74+
}
75+
}
76+
});
77+
78+
String timeoutResult = "TIMEOUT";
79+
String responseContent = WebClient.builder()
80+
.clientConnector(new JettyClientHttpConnector(httpClient()))
81+
.build()
82+
.get()
83+
.uri(new URI(uri()))
84+
.retrieve()
85+
.bodyToMono(String.class)
86+
.timeout(Duration.ofMillis(timeout), Mono.just(timeoutResult))
87+
.block();
88+
89+
Assert.assertEquals(timeoutResult, responseContent);
90+
}
5791
}

0 commit comments

Comments
 (0)