aboutsummaryrefslogtreecommitdiffstats
path: root/spring-utils
diff options
context:
space:
mode:
authorSuresh Charan <suresh.charan@bell.ca>2023-02-23 17:39:27 -0500
committerSuresh Charan <suresh.charan@bell.ca>2023-02-27 09:37:27 -0500
commit3440fabe4f0abdd43f7f60fe9f1d8d30f907819b (patch)
treeac2bdfeedca4ea3776045976df428a077ff7d245 /spring-utils
parent9cd5f32432c1f4d16abd0eb6c2ae9f495156f4b9 (diff)
Fixed sonar issues in policy-common
Reduced technical debt by fixing sonar issues Issue-ID: POLICY-4536 Change-Id: I9f8366ea49ab4e5541d64db2fe1f6e8f138ce763 Signed-off-by: Suresh Charan <suresh.charan@bell.ca>
Diffstat (limited to 'spring-utils')
-rw-r--r--spring-utils/src/main/java/org/onap/policy/common/spring/utils/YamlHttpMessageConverter.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/spring-utils/src/main/java/org/onap/policy/common/spring/utils/YamlHttpMessageConverter.java b/spring-utils/src/main/java/org/onap/policy/common/spring/utils/YamlHttpMessageConverter.java
index d7dc96a9..5fa02608 100644
--- a/spring-utils/src/main/java/org/onap/policy/common/spring/utils/YamlHttpMessageConverter.java
+++ b/spring-utils/src/main/java/org/onap/policy/common/spring/utils/YamlHttpMessageConverter.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022-2023 Bell Canada. 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.
@@ -73,14 +73,14 @@ public class YamlHttpMessageConverter extends AbstractGenericHttpMessageConverte
protected final void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage)
throws IOException {
try (var writer = getWriter(outputMessage)) {
- writeInternal(object, type, writer);
+ writeInternal(object, writer);
writer.flush();
} catch (Exception ex) {
throw new HttpMessageNotWritableException("Could not write YAML: " + ex.getMessage(), ex);
}
}
- private void writeInternal(Object object, @Nullable Type type, Writer writer) {
+ private void writeInternal(Object object, Writer writer) {
TRANSLATOR.toYaml(writer, object);
}
@@ -101,7 +101,8 @@ public class YamlHttpMessageConverter extends AbstractGenericHttpMessageConverte
}
private static Charset getCharset(HttpHeaders headers) {
- Charset charset = (headers.getContentType() == null ? null : headers.getContentType().getCharset());
+ MediaType contentType = headers.getContentType();
+ Charset charset = (contentType == null ? null : contentType.getCharset());
return (charset != null ? charset : DEFAULT_CHARSET);
}
-} \ No newline at end of file
+}