fix try block
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / admin / RESTfulPAPEngine.java
index a8831ea..b14a881 100644 (file)
@@ -455,10 +455,13 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
                        // get the response content into a String
                        String json = null;
                                // read the inputStream into a buffer (trick found online scans entire input looking for end-of-file)
-                           java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream());
-                           scanner.useDelimiter("\\A");
-                           json =  scanner.hasNext() ? scanner.next() : "";
-                           scanner.close();
+                           try(java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream())) {
+                                               scanner.useDelimiter("\\A");
+                                               json = scanner.hasNext() ? scanner.next() : "";
+                                       }catch(Exception e) {
+                                               LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to read inputStream from connection: " + e, e);
+                               throw e;
+                                       }
                            LOGGER.info("JSON response from PAP: " + json);
                        
                        // convert Object sent as JSON into local object