Skip to content

Netty4ClientHttpRequestFactory should configure a default SslContext [SPR-14744] #19310

Closed
@spring-projects-issues

Description

@spring-projects-issues

Joaquim Pedro Silveira opened SPR-14744 and commented

As title describes, when trying to use AsyncRestTemplate with a Netty4ClientHttpRequestFactory, the client is not properly configured by default for https servers.

I also tried with the following code, which results in an HttpClientErrorException:

@Test
public void asyncRestNetty() throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    AsyncRestTemplate restTemplate = new AsyncRestTemplate(new Netty4ClientHttpRequestFactory());
    // the client should send a request to an HTTPS server
    ListenableFuture<ResponseEntity<String>> listenableFuture = restTemplate.getForEntity("https://example.org/some/resource", String.class);
    listenableFuture.addCallback((result) -> {
        latch.countDown();
        assertThat(result, is(notNullValue()));
        assertThat(result.getBody(), is(not(isEmptyOrNullString())));
    }, (throwable) -> {
        latch.countDown();
        fail(throwable.getMessage());
    });
    if (!latch.await(30, TimeUnit.SECONDS)) {
        fail("Timeout");
    }
}

Affects: 4.3.3

Reference URL: http://stackoverflow.com/questions/39639467/spring-resttemplate-asyncresttemplate-with-netty4-hangs-forever

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions