From 3440fabe4f0abdd43f7f60fe9f1d8d30f907819b Mon Sep 17 00:00:00 2001 From: Suresh Charan Date: Thu, 23 Feb 2023 17:39:27 -0500 Subject: 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 --- .../policy/common/spring/utils/YamlHttpMessageConverter.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'spring-utils') 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 +} -- cgit 1.2.3-korg