Fix for Issue #549 : Update Exception Handling Code in Aggregator Microservice (#958)

*  Fix for Issue##549

Catch ClientProtocolException and Update Error Logs

* Fix indentation, checkstyle errors
This commit is contained in:
Arpit Jain 2019-10-06 20:57:39 +05:30 committed by Ilkka Seppälä
parent 933de30d42
commit 60171e3c87
2 changed files with 10 additions and 4 deletions

View File

@ -22,6 +22,7 @@
*/
package com.iluwatar.aggregator.microservices;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
@ -49,8 +50,10 @@ public class ProductInformationClientImpl implements ProductInformationClient {
try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) {
response = EntityUtils.toString(httpResponse.getEntity());
}
} catch (IOException e) {
LOGGER.error("Exception caught.", e);
} catch (ClientProtocolException cpe) {
LOGGER.error("ClientProtocolException Occured", cpe);
} catch (IOException ioe) {
LOGGER.error("IOException Occurred", ioe);
}
return response;
}

View File

@ -22,6 +22,7 @@
*/
package com.iluwatar.aggregator.microservices;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
@ -49,8 +50,10 @@ public class ProductInventoryClientImpl implements ProductInventoryClient {
try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) {
response = EntityUtils.toString(httpResponse.getEntity());
}
} catch (IOException e) {
LOGGER.error("Exception caught.", e);
} catch (ClientProtocolException cpe) {
LOGGER.error("ClientProtocolException Occured", cpe);
} catch (IOException ioe) {
LOGGER.error("IOException Occurred", ioe);
}
return Integer.parseInt(response);
}