Reverting "Merge "fix try block""
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / admin / PolicyRestController.java
index 21f15bb..8df9d1b 100644 (file)
@@ -338,17 +338,10 @@ public class PolicyRestController extends RestrictedBaseController{
                                // get the response content into a String
                                String responseJson = null;
                                // read the inputStream into a buffer (trick found online scans entire input looking for end-of-file)
-                               try(java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream())) {
-                                       scanner.useDelimiter("\\A");
-                                       responseJson = scanner.hasNext() ? scanner.next() : "";
-                               } catch (Exception e) {
-                                       //Reason for rethrowing the exception is if any exception occurs during reading of inputsteam
-                                       //then the exception handling is done by the outer block without returning the response immediately
-                                       //Also finally block is existing only in outer block and not here so all exception handling is
-                                       //done in only one place
-                                       policyLogger.error("Exception Occured"+e);
-                                       throw e;
-                               }
+                               java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream());
+                               scanner.useDelimiter("\\A");
+                               responseJson =  scanner.hasNext() ? scanner.next() : "";
+                               scanner.close();
                                policyLogger.info("JSON response from PAP: " + responseJson);
                                return responseJson;
                        }