summaryrefslogtreecommitdiffstats
path: root/cps-rest/src/main/java
diff options
context:
space:
mode:
authorClaudio David Gasparini <claudio.gasparini@pantheon.tech>2021-01-11 16:42:30 +0100
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>2021-01-12 10:41:45 +0100
commit9afc8d1448a6a913db56304d3bc80cd92c141d0f (patch)
treecdf41d77a07a4e62874941d06d16447b66d148a2 /cps-rest/src/main/java
parenta3c45cab5d3a268c16410f4962b18043b7c04bad (diff)
Enable spotbugs and fix spotbugs warns
Issue-ID: CPS-159 Signed-off-by: Claudio David Gasparini <claudio.gasparini@pantheon.tech> Change-Id: Iee572fd740689a172ca599123b0751b5e909223a
Diffstat (limited to 'cps-rest/src/main/java')
-rw-r--r--cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java b/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java
index 0c527a5565..c53d1a42a6 100644
--- a/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java
@@ -19,10 +19,12 @@
package org.onap.cps.rest.utils;
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.opendaylight.yangtools.yang.common.YangConstants.RFC6020_YANG_FILE_EXTENSION;
import com.google.common.collect.ImmutableMap;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -47,7 +49,7 @@ public class MultipartFileUtil {
}
private static String extractYangResourceName(final MultipartFile multipartFile) {
- final String fileName = multipartFile.getOriginalFilename();
+ final String fileName = checkNotNull(multipartFile.getOriginalFilename(), "Missing filename.");
if (!fileName.endsWith(RFC6020_YANG_FILE_EXTENSION)) {
throw new ModelValidationException("Unsupported file type.",
String.format("Filename %s does not end with '%s'", fileName, RFC6020_YANG_FILE_EXTENSION));
@@ -57,7 +59,7 @@ public class MultipartFileUtil {
private static String extractYangResourceContent(final MultipartFile multipartFile) {
try {
- return new String(multipartFile.getBytes());
+ return new String(multipartFile.getBytes(), StandardCharsets.UTF_8);
} catch (final IOException e) {
throw new CpsException("Cannot read the resource file.", e.getMessage(), e);
}