Skip to content

Commit

Permalink
Issue #22 - Using Jetty with Spring Webclient causes thread leak.
Browse files Browse the repository at this point in the history
Added test case - there appear to be no issue though.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Sep 7, 2020
1 parent c58b25c commit 6d86c99
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/test/java/org/eclipse/jetty/reactive/client/ReactorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
package org.eclipse.jetty.reactive.client;

import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.URI;
import java.time.Duration;
import java.util.Random;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -27,6 +30,7 @@
import org.testng.Assert;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import reactor.core.publisher.Mono;

public class ReactorTest extends AbstractTest {
@Factory(dataProvider = "protocols", dataProviderClass = AbstractTest.class)
Expand Down Expand Up @@ -54,4 +58,34 @@ protected void service(String target, Request jettyRequest, HttpServletRequest r
Assert.assertNotNull(responseContent);
Assert.assertEquals(data, responseContent);
}

@Test
public void testTotalTimeout() throws Exception {
long timeout = 1000;
String result = "HELLO";
prepare(new EmptyHandler() {
@Override
protected void service(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Thread.sleep(2 * timeout);
response.getWriter().write(result);
} catch (InterruptedException x) {
throw new InterruptedIOException();
}
}
});

String timeoutResult = "TIMEOUT";
String responseContent = WebClient.builder()
.clientConnector(new JettyClientHttpConnector(httpClient()))
.build()
.get()
.uri(new URI(uri()))
.retrieve()
.bodyToMono(String.class)
.timeout(Duration.ofMillis(timeout), Mono.just(timeoutResult))
.block();

Assert.assertEquals(timeoutResult, responseContent);
}
}

0 comments on commit 6d86c99

Please sign in to comment.