fixed sonar issue in JsonUtil.java 19/64119/1
authorSandeep J <sandeejh@in.ibm.com>
Sun, 2 Sep 2018 20:53:42 +0000 (02:23 +0530)
committerSandeep J <sandeejh@in.ibm.com>
Sun, 2 Sep 2018 20:53:54 +0000 (02:23 +0530)
fixed sonar issue detailed in SO-950

Issue-ID: SO-950
Change-Id: Ic8089706054c785d4ef31957617b44222ab0030f
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java

index c12cd7d..64032e2 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -51,7 +53,7 @@ public class JsonUtil {
    * Mapper.
    */
   private static final ObjectMapper MAPPER = new ObjectMapper();
-
+  private static final String UNMARSHAL_FAIL_MSG="fail to unMarshal json";
   static {
     MAPPER.setConfig(MAPPER.getDeserializationConfig().without(
         DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
@@ -82,8 +84,8 @@ public class JsonUtil {
       return MAPPER.readValue(jsonstr, type);
     } catch (IOException e) {
       LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
-          "fail to unMarshal json", e);
-      throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json");
+          UNMARSHAL_FAIL_MSG, e);
+      throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG);
     }
   }
 
@@ -100,8 +102,8 @@ public class JsonUtil {
       return MAPPER.readValue(jsonstr, type);
     } catch (IOException e) {
       LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
-          "fail to unMarshal json", e);
-      throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json");
+          UNMARSHAL_FAIL_MSG, e);
+      throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG);
     }
   }