From: Fiete Ostkamp Date: Fri, 11 Jul 2025 10:51:16 +0000 (+0200) Subject: Use a dependency-injected RestTemplateBuilder to create RestTemplates X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=2a4abed10c30ff1974f5aa5ccaf3043b178bff55;p=so.git Use a dependency-injected RestTemplateBuilder to create RestTemplates - RestTemplate t = new RestTemplate() breaks tracing - use dependency-injected RestTemplateBuilder to create RestTemplate Issue-ID: SO-4194 Change-Id: I7fc30acfc07565f2468275062a128108e4c4b8c0 Signed-off-by: Fiete Ostkamp --- diff --git a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java index f8587ff776..e378a4ee48 100644 --- a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java +++ b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,6 +25,7 @@ import org.onap.so.configuration.rest.HttpComponentsClientConfiguration; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; @@ -42,8 +43,8 @@ public class RestTemplateConfig { @Bean @Primary - public RestTemplate restTemplate() { - final RestTemplate restTemplate = new RestTemplate(); + public RestTemplate restTemplate(RestTemplateBuilder builder) { + final RestTemplate restTemplate = builder.build(); restTemplate .setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); restTemplate.getInterceptors().add(new SOSpringClientFilter()); diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java index cc721d38b6..c20458d9b7 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java @@ -40,6 +40,8 @@ import javax.persistence.TemporalType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.commons.lang3.builder.ToStringBuilder; import org.onap.so.requestsdb.TimestampXMLAdapter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.DateDeserializers.TimestampDeserializer; @MappedSuperclass public abstract class InfraRequests implements java.io.Serializable { @@ -67,7 +69,9 @@ public abstract class InfraRequests implements java.io.Serializable { private Long progress; @Column(name = "START_TIME") + @JsonDeserialize(using = TimestampDeserializer.class) private Timestamp startTime; + @JsonDeserialize(using = TimestampDeserializer.class) @Column(name = "END_TIME") private Timestamp endTime; @Column(name = "SOURCE", length = 45)