Skip to content

HttpComponentsClientHttpRequestFactory.setBufferRequestBody(false) does not stop OutOfMemoryError [SPR-11977] #16593

Closed
@spring-projects-issues

Description

@spring-projects-issues

Syam Sarangadharan opened SPR-11977 and commented

I am using HttpComponentsClientHttpRequestFactory to establish HttpConnection pooling. I am getting OutOfMemoryError. To avoid this as suggested I used HttpComponentsClientHttpRequestFactory.setBufferRequestBody(false) to prevent the payload getting buffered. But still I get the same OutOfMemoryError.

Here is the code snippet.

public String send(String url, String request) throws RestClientException {

	// Create the HttpComponentsClientHttpRequestFactory
	HttpComponentsClientHttpRequestFactory preconfiguredHTTPInstance = new HttpComponentsClientHttpRequestFactory();

	// Set BufferRequestBody as false, default is true.
	preconfiguredHTTPInstance.setBufferRequestBody(false);
	preconfiguredHTTPInstance.setHttpClient(httpClient);

	RestTemplate restTemplate = new RestTemplate();
	restTemplate.setRequestFactory(preconfiguredHTTPInstance);
	restTemplate.getMessageConverters().add(new StringHttpMessageConverter());

	String responseString = restTemplate.postForObject(url, request, String.class);

	return responseString;
}

Affects: 4.0.6

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions