Pattern pattern = Pattern.compile("\\$([a-zA-Z0-9.:]*)");
Matcher match = pattern.matcher(configURL);
StringBuffer sb = new StringBuffer();
+ JsonReader jsonReader = null;
while (match.find()) {
LOGGER.info("Found Macro : " + match.group(1));
String replaceValue = matchValues.get(match.group(1));
connection = configURL.openConnection();
// InputStream in = connection.getInputStrem();
// LOGGER.info("The Body Content is : " + IOUtils.toString(in));
- JsonReader jsonReader = Json.createReader(connection.getInputStream());
+ jsonReader = Json.createReader(connection.getInputStream());
StringEntity input = new StringEntity(jsonReader.readObject().toString());
input.setContentType("application/json");
postRequest.setEntity(input);
LOGGER.error(e.getMessage() +e);
response = e.getMessage();
} finally {
+ if(jsonReader != null) {
+ try {
+ jsonReader.close();
+ } catch (Exception e) {
+ LOGGER.error("Exception Occured while closing the JsonReader"+e);
+ }
+ }
httpClient.getConnectionManager().shutdown();
}
} else if(matchValues.get("method").equalsIgnoreCase("PUT")) {
connection = configURL.openConnection();
//InputStream in = connection.getInputStream();
//LOGGER.info("The Body Content is : " + IOUtils.toString(in));
- JsonReader jsonReader = Json.createReader(connection.getInputStream());
+ jsonReader = Json.createReader(connection.getInputStream());
StringEntity input = new StringEntity(jsonReader.readObject().toString());
input.setContentType("application/json");
putRequest.setEntity(input);
LOGGER.error(e.getMessage() +e);
response = e.getMessage();
}finally {
+ if(jsonReader != null) {
+ try {
+ jsonReader.close();
+ } catch (Exception e) {
+ LOGGER.error("Exception Occured while closing the JsonReader"+e);
+ }
+ }
httpClient.getConnectionManager().shutdown();
}
}