Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(web): fix groovy compilation failure due to missing type conversions during upgrade to springboot 2.5.15 #1730

Merged
merged 1 commit into from
Nov 6, 2023

Conversation

j-sandy
Copy link
Contributor

@j-sandy j-sandy commented Nov 6, 2023

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#<init>(java.util.List <com.netflix.spinnaker.kork.web.selector.ServiceSelector>) with arguments [java.util.List <? extends com.netflix.spinnaker.kork.web.selector.ServiceSelector>]
 @ 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 <T>, 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.

…versions 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#<init>(java.util.List <com.netflix.spinnaker.kork.web.selector.ServiceSelector>) with arguments [java.util.List <? extends com.netflix.spinnaker.kork.web.selector.ServiceSelector>]
 @ 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 <T>, 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`.
@@ -317,7 +318,7 @@ class GateConfig extends RedisHttpSessionConfiguration {
}

private <T> T buildService(String serviceName, Class<T> type, Endpoint endpoint) {
ObjectMapper objectMapper = objectMapperBuilder.build()
ObjectMapper objectMapper = objectMapperBuilder.build() as ObjectMapper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be so lovely to convert this to java one day.

@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Nov 6, 2023
@mergify mergify bot added the auto merged label Nov 6, 2023
@mergify mergify bot merged commit f748e03 into spinnaker:master Nov 6, 2023
5 checks passed
@j-sandy j-sandy deleted the typecast branch November 7, 2023 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants