diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2021-04-13 17:16:58 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-04-13 17:16:58 +0000 |
commit | 322b149685bb2f9405999f5a299130694d1b8fe3 (patch) | |
tree | 1aac8e2667cf8a29984ee03bff5623fdecf9161a /utils/src/main | |
parent | 1cb818e3cbd6154762f908be8698317fa10fbc49 (diff) | |
parent | 1155833a3d4e271f495e0ca40ea591919aa11b78 (diff) |
Merge "Revert "Modify StandardCoder to handle empty source""
Diffstat (limited to 'utils/src/main')
-rw-r--r-- | utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java b/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java index 3b4f3c23..7f5e3b85 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java +++ b/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java @@ -1,8 +1,8 @@ -/*- +/* * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,6 @@ import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; -import org.apache.commons.lang3.StringUtils; import org.onap.policy.common.gson.DoubleConverter; import org.onap.policy.common.gson.GsonMessageBodyHandler; @@ -342,17 +341,8 @@ public class StandardCoder implements Coder { * @param json json string to be decoded * @param clazz class of object to be decoded * @return the object represented by the given json string - * @throws CoderException if the source is empty */ - protected <T> T fromJson(String json, Class<T> clazz) throws CoderException { - if (json == null) { - return null; - } - - if (StringUtils.isBlank(json)) { - throw new CoderException("source string is empty"); - } - + protected <T> T fromJson(String json, Class<T> clazz) { return convertFromDouble(clazz, gson.fromJson(json, clazz)); } @@ -362,16 +352,9 @@ public class StandardCoder implements Coder { * @param source source from which to read the json string to be decoded * @param clazz class of object to be decoded * @return the object represented by the given json string - * @throws CoderException if the source is empty */ - protected <T> T fromJson(Reader source, Class<T> clazz) throws CoderException { - T object = gson.fromJson(source, clazz); - - if (object == null) { - throw new CoderException("source is empty"); - } - - return convertFromDouble(clazz, object); + protected <T> T fromJson(Reader source, Class<T> clazz) { + return convertFromDouble(clazz, gson.fromJson(source, clazz)); } /** |