#vulnerable code 
                             @Override
	public void send() throws Exception {

		logger.debug("event=send_sync_http_request endpoint=" + endpoint + "\" message=\"" + message + "\"");

		if ((message == null) || (endpoint == null)) {
			logger.debug("event=send_http_request error_code=MissingParameters endpoint=" + endpoint + "\" message=\"" + message + "\"");
			throw new Exception("Message and Endpoint must both be set");
		}

		HttpPost httpPost = new HttpPost(endpoint);
		StringEntity stringEntity = new StringEntity(message);
		httpPost.setEntity(stringEntity);
		composeHeader(httpPost);


		HttpResponse response = httpClient.execute(httpPost);
		int statusCode = response.getStatusLine().getStatusCode();

		HttpEntity entity = response.getEntity();

		// accept all 2xx status codes

		if (statusCode > 200 || statusCode >= 300) {

			if (entity != null) {

				InputStream instream = entity.getContent();
				InputStreamReader responseReader = new InputStreamReader(instream);
				StringBuffer buffer = new StringBuffer();

				char []arr = new char[1024];
				int size = 0;

				while ((size = responseReader.read(arr, 0, arr.length)) != -1) {
					buffer.append(arr, 0, size);
				}      

				instream.close();
			}

			logger.debug("event=http_post_error endpoint=" + endpoint + " error_code=" + statusCode);
			throw new CMBException(new CMBErrorCodes(statusCode, "HttpError"), "Unreachable endpoint " + endpoint + " returns status code " + statusCode);

		} else {

			if (entity != null) {
				EntityUtils.consume(entity);
			}
		}
	} 
                            #location 9 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             @Override
	public void send() throws Exception {

		if ((message == null) || (endpoint == null)) {
			logger.debug("event=send_http_request error_code=MissingParameters endpoint=" + endpoint + "\" message=\"" + message + "\"");
			throw new Exception("Message and Endpoint must both be set");
		}

		HttpPost httpPost = new HttpPost(endpoint);

		String msg = null;
		
		if (message.getMessageStructure() == CNSMessageStructure.json) {
			msg = message.getProtocolSpecificMessage(CnsSubscriptionProtocol.http);
		} else {
			msg = message.getMessage();
		}
		
		if (!rawMessageDelivery && message.getMessageType() == CNSMessageType.Notification) {
			msg = com.comcast.cns.util.Util.generateMessageJson(message, CnsSubscriptionProtocol.http);
		}
		
		logger.info("event=send_sync_http_request endpoint=" + endpoint + "\" message=\"" + msg + "\"");

		StringEntity stringEntity = new StringEntity(msg);
		httpPost.setEntity(stringEntity);
		composeHeader(httpPost);

		HttpResponse response = httpClient.execute(httpPost);
		int statusCode = response.getStatusLine().getStatusCode();

		HttpEntity entity = response.getEntity();

		// accept all 2xx status codes

		if (statusCode > 200 || statusCode >= 300) {

			if (entity != null) {

				InputStream instream = entity.getContent();
				InputStreamReader responseReader = new InputStreamReader(instream);
				StringBuffer buffer = new StringBuffer();

				char []arr = new char[1024];
				int size = 0;

				while ((size = responseReader.read(arr, 0, arr.length)) != -1) {
					buffer.append(arr, 0, size);
				}      

				instream.close();
			}

			logger.debug("event=http_post_error endpoint=" + endpoint + " error_code=" + statusCode);
			throw new CMBException(new CMBErrorCodes(statusCode, "HttpError"), "Unreachable endpoint " + endpoint + " returns status code " + statusCode);

		} else {

			if (entity != null) {
				EntityUtils.consume(entity);
			}
		}
	}