summaryrefslogtreecommitdiffstats
path: root/spring-utils
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2023-02-28 12:09:22 +0000
committerGerrit Code Review <gerrit@onap.org>2023-02-28 12:09:22 +0000
commit9e3379cf3cebcd727b0777583a40f28fec041b99 (patch)
tree99ab38a19e63e793d47ccfc7db642a79f0ea0004 /spring-utils
parent31e0f31ba2cfb6b2342af8829fd65897c49295a2 (diff)
parent3440fabe4f0abdd43f7f60fe9f1d8d30f907819b (diff)
Merge "Fixed sonar issues in policy-common"
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
+}