aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PDP-REST/src/main
diff options
context:
space:
mode:
authoreramkve <ram.krishna.verma@ericsson.com>2018-03-16 15:44:07 +0000
committereramkve <ram.krishna.verma@ericsson.com>2018-03-20 15:28:04 +0000
commiteef3c224cb6cad4b82a96938ade1e42ca881eea2 (patch)
tree37fc08a9b229e5634c0ffb983227f9f563ac7766 /ONAP-PDP-REST/src/main
parent44fd25bcbb86f8600ec88eeeac6bb8312672c470 (diff)
Fix all bugs reported by Sonar in policy/engine
Code fixes for 27 bugs reported by Sonar in policy/engine Change-Id: I96da96b38a2e2954ec549e5cdf6ed3ad1d76722c Issue-ID: POLICY-662 Signed-off-by: eramkve <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'ONAP-PDP-REST/src/main')
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetDictionaryService.java2
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java11
2 files changed, 11 insertions, 2 deletions
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetDictionaryService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetDictionaryService.java
index d3628f3c1..9b86204e0 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetDictionaryService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetDictionaryService.java
@@ -247,7 +247,7 @@ public class GetDictionaryService {
jsonString = jsonString.replace("microServiceDictionaryDatas", "DictionaryDatas");
break;
default:
- return null;
+ break;
}
return jsonString;
}
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java
index 8258aba1a..af7112ebd 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java
@@ -341,12 +341,13 @@ public class PDPServices {
pdpConfigLocation = pdpConfigLocation.replace("/", File.separator);
}
InputStream inputStream = null;
+ JsonReader jsonReader = null;
try {
inputStream = new FileInputStream(new File(pdpConfigLocation));
try {
if (pdpConfigLocation.endsWith("json")) {
pdpResponse.setType(PolicyType.JSON);
- JsonReader jsonReader = Json.createReader(inputStream);
+ jsonReader = Json.createReader(inputStream);
pdpResponse.setConfig(jsonReader.readObject().toString());
jsonReader.close();
} else if (pdpConfigLocation.endsWith("xml")) {
@@ -400,6 +401,14 @@ public class PDPServices {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
throw new PDPException(XACMLErrorConstants.ERROR_PROCESS_FLOW +
"Cannot open a connection to the configURL", e);
+ } finally {
+ if(jsonReader != null) {
+ try {
+ jsonReader.close();
+ } catch (Exception e) {
+ LOGGER.error("Exception Occured while closing the JsonReader"+e);
+ }
+ }
}
} catch (FileNotFoundException e) {
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
f='#n326'>326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472