Skip to content

Conversation

@rhkiswani
Copy link
Owner

No description provided.

if (json == null){
throw new HttpClientException(SmartException.NULL_VAL, "Json Object");
}
CloseableHttpClient c = HttpClientBuilder.create().build();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer

Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: c. Currently, there are execution paths that do not contain closure statements. Either a) close c in a try-finally block or b) close the resource by declaring c in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

}

private CloseableHttpClient prepareRequest(HttpRequestBase method, Map<String, String> params) throws UnsupportedEncodingException {
CloseableHttpClient c = HttpClientBuilder.create().build();
Copy link
Owner Author

@rhkiswani rhkiswani Dec 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem
This line of code contains a resource that might not be closed properly. Resource leaks can cause your system to slow down or crash.

Fix
Consider closing the following resource: c. The resource is returned at line: 119. There are other execution paths that neither close the resource nor return it, e.g., when exception is thrown by BasicNameValuePair constructor, and if-branch is taken at line 109. Either a) close c in a try-finally block or b) close the resource by declaring c in a try-with-resources block.

More info
View resource management guidelines at oracle.com (external link).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants