From f210cd0381d209cde3c44d0b2a502dc953ff2d75 Mon Sep 17 00:00:00 2001 From: j-sandy <30489233+j-sandy@users.noreply.github.com> Date: Mon, 6 Nov 2023 19:01:59 +0530 Subject: [PATCH] refactor(web): fix groovy compilation failure due to missing type conversions during upgrade to springboot 2.5.15 While upgrading springboot 2.5.15, encounter below error in gate-web module: ``` startup failed: /gate/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy: 231: [Static type checking] - Cannot call com.netflix.spinnaker.kork.web.selector.SelectableService#(java.util.List ) with arguments [java.util.List ] @ line 231, column 9. new SelectableService(selectors + defaultSelector), dynamicConfigService, contextProvider) ^ /gate/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy: 322: [Static type checking] - Cannot find matching method java.lang.Object#configure(com.fasterxml.jackson.databind.SerializationFeature, boolean). Please check if the declared type is correct and if the method exists. @ line 322, column 7. objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); ^ /gate/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy: 324: [Static type checking] - Cannot find matching method com.netflix.spinnaker.kork.client.ServiceClientProvider#getService(java.lang.Class , com.netflix.spinnaker.config.DefaultServiceEndpoint, T). Please check if the declared type is correct and if the method exists. @ line 324, column 5. serviceClientProvider.getService(type, new DefaultServiceEndpoint(serviceName, endpoint.url), objectMapper) ^ 3 errors > Task :gate-web:compileGroovy FAILED ``` To fix this, explicitly mentioned the type of object reference as `ServiceSelector defaultSelector` and typecasted the object `objectMapperBuilder.build() as ObjectMapper`. --- .../com/netflix/spinnaker/gate/config/GateConfig.groovy | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy index 4cda1529ae..233667d5ce 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy @@ -23,6 +23,7 @@ import com.netflix.spectator.api.Registry import com.netflix.spinnaker.config.DefaultServiceEndpoint import com.netflix.spinnaker.config.OkHttp3ClientConfiguration import com.netflix.spinnaker.config.PluginsAutoConfiguration +import com.netflix.spinnaker.config.ServiceEndpoint import com.netflix.spinnaker.fiat.shared.FiatClientConfigurationProperties import com.netflix.spinnaker.fiat.shared.FiatPermissionEvaluator import com.netflix.spinnaker.fiat.shared.FiatService @@ -216,7 +217,7 @@ class GateConfig extends RedisHttpSessionConfiguration { // priority: 2 // origin: deck - def defaultSelector = new DefaultServiceSelector( + ServiceSelector defaultSelector = new DefaultServiceSelector( defaultClouddriverService, 1, null) @@ -317,7 +318,7 @@ class GateConfig extends RedisHttpSessionConfiguration { } private T buildService(String serviceName, Class type, Endpoint endpoint) { - ObjectMapper objectMapper = objectMapperBuilder.build() + ObjectMapper objectMapper = objectMapperBuilder.build() as ObjectMapper if(serviceName.equals("echo")) { objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); }