summaryrefslogtreecommitdiffstats
path: root/cps-rest/src
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2021-01-12 15:30:20 +0000
committerGerrit Code Review <gerrit@onap.org>2021-01-12 15:30:20 +0000
commit0e337e84e2edafc0b7cefd86ca596da1fd8e054a (patch)
tree3395207bb2e1cd0bded180d3f3376372b7530cc4 /cps-rest/src
parent6ec5273ae659a46dff05bb7993b77202786c92db (diff)
parent9afc8d1448a6a913db56304d3bc80cd92c141d0f (diff)
Merge "Enable spotbugs and fix spotbugs warns"
Diffstat (limited to 'cps-rest/src')
-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);
}