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(tests): replace HashSet.Of() and HashMap.Of() with Set.Of() and Map.Of() during upgrade to spring boot 2.7.x #1162

Closed
wants to merge 1 commit into from

Conversation

j-sandy
Copy link
Contributor

@j-sandy j-sandy commented May 24, 2024

While upgrading spring boot 2.7.18, encounter below errors during test compilation of fiat-roles module:

No signature of method: static java.util.HashSet.of() is applicable for argument types: (com.netflix.spinnaker.fiat.model.resources.Role) values: [Role(resourceType=role, name=role1, source=null)]
Possible solutions: is(java.lang.Object), max(), any(), sort(), sum(), min()
groovy.lang.MissingMethodException: No signature of method: static java.util.HashSet.of() is applicable for argument types: (com.netflix.spinnaker.fiat.model.resources.Role) values: [Role(resourceType=role, name=role1, source=null)]
Possible solutions: is(java.lang.Object), max(), any(), sort(), sum(), min()
        at com.netflix.spinnaker.fiat.permissions.DefaultPermissionsResolverSpec.should resolve resources for users and service accounts(DefaultPermissionsResolverSpec.groovy:343)
No signature of method: static java.util.HashMap.of() is applicable for argument types: (String, String, String, String) values: [foo, bar, xyz, pqr]
Possible solutions: any(), sort(), notify(), wait(), size(), clone()
groovy.lang.MissingMethodException: No signature of method: static java.util.HashMap.of() is applicable for argument types: (String, String, String, String) values: [foo, bar, xyz, pqr]
Possible solutions: any(), sort(), notify(), wait(), size(), clone()
        at com.netflix.spinnaker.fiat.providers.DefaultApplicationProviderSpec.enable calling Clouddriver during application load based on config(DefaultApplicationProviderSpec.groovy:170)

No signature of method: static java.util.HashMap.of() is applicable for argument types: (String, String, String, String) values: [foo, bar, xyz, pqr]
Possible solutions: any(), sort(), notify(), wait(), size(), clone()
groovy.lang.MissingMethodException: No signature of method: static java.util.HashMap.of() is applicable for argument types: (String, String, String, String) values: [foo, bar, xyz, pqr]
Possible solutions: any(), sort(), notify(), wait(), size(), clone()
        at com.netflix.spinnaker.fiat.providers.DefaultApplicationProviderSpec.should suppress details when loading all applications(DefaultApplicationProviderSpec.groovy:227)

Spring boot 2.7.18 brings groovy 3.0.19 as transitive dependency. The root cause of the issue is a breaking change introduced from groovy 3.0.18 onwards, that allows a Java class to inherit static methods from its interface. To fix these issues replacing the HashSet.Of() and HashMap.Of() with Set.Of() and Map.Of().

http://groovy-lang.org/changelogs/changelog-3.0.18.html
https://issues.apache.org/jira/browse/GROOVY-8164

Before:

$ ./gradlew fiat-roles:dI --dependency org.codehaus.groovy --configuration testCompileClasspath

> Task :fiat-roles:dependencyInsight
org.codehaus.groovy:groovy:3.0.17
  Variant compile:
    | Attribute Name                 | Provided | Requested         |
    |--------------------------------|----------|-------------------|
    | org.gradle.status              | release  |                   |
    | org.gradle.category            | library  | library           |
    | org.gradle.libraryelements     | jar      | classes+resources |
    | org.gradle.usage               | java-api | java-api          |
    | org.gradle.dependency.bundling |          | external          |
    | org.gradle.jvm.environment     |          | standard-jvm      |
    | org.gradle.jvm.version         |          | 11                |
   Selection reasons:
      - By constraint
      - Forced

org.codehaus.groovy:groovy:3.0.17
\--- io.spinnaker.kork:kork-bom:7.227.0
     \--- testCompileClasspath

org.codehaus.groovy:groovy:3.0.8 -> 3.0.17
+--- org.spockframework:spock-core:2.0-groovy-3.0
|    +--- testCompileClasspath (requested org.spockframework:spock-core)
|    +--- io.spinnaker.kork:kork-bom:7.227.0
|    |    \--- testCompileClasspath
|    \--- org.spockframework:spock-spring:2.0-groovy-3.0
|         +--- testCompileClasspath (requested org.spockframework:spock-spring)
|         \--- io.spinnaker.kork:kork-bom:7.227.0 (*)
\--- org.spockframework:spock-spring:2.0-groovy-3.0 (*)

After:

$ ./gradlew fiat-roles:dI --dependency org.codehaus.groovy --configuration testCompileClasspath

> Task :fiat-roles:dependencyInsight
org.codehaus.groovy:groovy:3.0.19
  Variant compile:
    | Attribute Name                 | Provided | Requested         |
    |--------------------------------|----------|-------------------|
    | org.gradle.status              | release  |                   |
    | org.gradle.category            | library  | library           |
    | org.gradle.libraryelements     | jar      | classes+resources |
    | org.gradle.usage               | java-api | java-api          |
    | org.gradle.dependency.bundling |          | external          |
    | org.gradle.jvm.environment     |          | standard-jvm      |
    | org.gradle.jvm.version         |          | 11                |
   Selection reasons:
      - By constraint
      - Forced

org.codehaus.groovy:groovy:3.0.19
\--- io.spinnaker.kork:kork-bom:sb2718-SNAPSHOT
     \--- testCompileClasspath

org.codehaus.groovy:groovy:3.0.8 -> 3.0.19
+--- org.spockframework:spock-core:2.0-groovy-3.0
|    +--- testCompileClasspath (requested org.spockframework:spock-core)
|    +--- io.spinnaker.kork:kork-bom:sb2718-SNAPSHOT
|    |    \--- testCompileClasspath
|    \--- org.spockframework:spock-spring:2.0-groovy-3.0
|         +--- testCompileClasspath (requested org.spockframework:spock-spring)
|         \--- io.spinnaker.kork:kork-bom:sb2718-SNAPSHOT (*)
\--- org.spockframework:spock-spring:2.0-groovy-3.0 (*)

… static methods from its interfaces during upgrade to spring boot 2.7.x

While upgrading spring boot 2.7.18, encounter below errors during test compilation of fiat-roles module:
```
No signature of method: static java.util.HashSet.of() is applicable for argument types: (com.netflix.spinnaker.fiat.model.resources.Role) values: [Role(resourceType=role, name=role1, source=null)]
Possible solutions: is(java.lang.Object), max(), any(), sort(), sum(), min()
groovy.lang.MissingMethodException: No signature of method: static java.util.HashSet.of() is applicable for argument types: (com.netflix.spinnaker.fiat.model.resources.Role) values: [Role(resourceType=role, name=role1, source=null)]
Possible solutions: is(java.lang.Object), max(), any(), sort(), sum(), min()
        at com.netflix.spinnaker.fiat.permissions.DefaultPermissionsResolverSpec.should resolve resources for users and service accounts(DefaultPermissionsResolverSpec.groovy:343)
```
```
No signature of method: static java.util.HashMap.of() is applicable for argument types: (String, String, String, String) values: [foo, bar, xyz, pqr]
Possible solutions: any(), sort(), notify(), wait(), size(), clone()
groovy.lang.MissingMethodException: No signature of method: static java.util.HashMap.of() is applicable for argument types: (String, String, String, String) values: [foo, bar, xyz, pqr]
Possible solutions: any(), sort(), notify(), wait(), size(), clone()
        at com.netflix.spinnaker.fiat.providers.DefaultApplicationProviderSpec.enable calling Clouddriver during application load based on config(DefaultApplicationProviderSpec.groovy:170)

```
```
No signature of method: static java.util.HashMap.of() is applicable for argument types: (String, String, String, String) values: [foo, bar, xyz, pqr]
Possible solutions: any(), sort(), notify(), wait(), size(), clone()
groovy.lang.MissingMethodException: No signature of method: static java.util.HashMap.of() is applicable for argument types: (String, String, String, String) values: [foo, bar, xyz, pqr]
Possible solutions: any(), sort(), notify(), wait(), size(), clone()
        at com.netflix.spinnaker.fiat.providers.DefaultApplicationProviderSpec.should suppress details when loading all applications(DefaultApplicationProviderSpec.groovy:227)

```
Spring boot 2.7.18 brings groovy 3.0.19 as transitive dependency. The root cause of the issue is a breaking change introduced from groovy 3.0.18 onwards, that allows a Java class to inherit static methods from its interface. To fix these issues replacing the HashSet.Of() and HashMap.Of() with Set.Of() and Map.Of().

http://groovy-lang.org/changelogs/changelog-3.0.18.html
https://issues.apache.org/jira/browse/GROOVY-8164

Before:
```
$ ./gradlew fiat-roles:dI --dependency org.codehaus.groovy --configuration testCompileClasspath

> Task :fiat-roles:dependencyInsight
org.codehaus.groovy:groovy:3.0.17
  Variant compile:
    | Attribute Name                 | Provided | Requested         |
    |--------------------------------|----------|-------------------|
    | org.gradle.status              | release  |                   |
    | org.gradle.category            | library  | library           |
    | org.gradle.libraryelements     | jar      | classes+resources |
    | org.gradle.usage               | java-api | java-api          |
    | org.gradle.dependency.bundling |          | external          |
    | org.gradle.jvm.environment     |          | standard-jvm      |
    | org.gradle.jvm.version         |          | 11                |
   Selection reasons:
      - By constraint
      - Forced

org.codehaus.groovy:groovy:3.0.17
\--- io.spinnaker.kork:kork-bom:7.227.0
     \--- testCompileClasspath

org.codehaus.groovy:groovy:3.0.8 -> 3.0.17
+--- org.spockframework:spock-core:2.0-groovy-3.0
|    +--- testCompileClasspath (requested org.spockframework:spock-core)
|    +--- io.spinnaker.kork:kork-bom:7.227.0
|    |    \--- testCompileClasspath
|    \--- org.spockframework:spock-spring:2.0-groovy-3.0
|         +--- testCompileClasspath (requested org.spockframework:spock-spring)
|         \--- io.spinnaker.kork:kork-bom:7.227.0 (*)
\--- org.spockframework:spock-spring:2.0-groovy-3.0 (*)

```

After:
```
$ ./gradlew fiat-roles:dI --dependency org.codehaus.groovy --configuration testCompileClasspath

> Task :fiat-roles:dependencyInsight
org.codehaus.groovy:groovy:3.0.19
  Variant compile:
    | Attribute Name                 | Provided | Requested         |
    |--------------------------------|----------|-------------------|
    | org.gradle.status              | release  |                   |
    | org.gradle.category            | library  | library           |
    | org.gradle.libraryelements     | jar      | classes+resources |
    | org.gradle.usage               | java-api | java-api          |
    | org.gradle.dependency.bundling |          | external          |
    | org.gradle.jvm.environment     |          | standard-jvm      |
    | org.gradle.jvm.version         |          | 11                |
   Selection reasons:
      - By constraint
      - Forced

org.codehaus.groovy:groovy:3.0.19
\--- io.spinnaker.kork:kork-bom:sb2718-SNAPSHOT
     \--- testCompileClasspath

org.codehaus.groovy:groovy:3.0.8 -> 3.0.19
+--- org.spockframework:spock-core:2.0-groovy-3.0
|    +--- testCompileClasspath (requested org.spockframework:spock-core)
|    +--- io.spinnaker.kork:kork-bom:sb2718-SNAPSHOT
|    |    \--- testCompileClasspath
|    \--- org.spockframework:spock-spring:2.0-groovy-3.0
|         +--- testCompileClasspath (requested org.spockframework:spock-spring)
|         \--- io.spinnaker.kork:kork-bom:sb2718-SNAPSHOT (*)
\--- org.spockframework:spock-spring:2.0-groovy-3.0 (*)

```
@j-sandy j-sandy marked this pull request as ready for review June 5, 2024 11:32
@dbyron-sf
Copy link
Contributor

included in #1165

@dbyron-sf dbyron-sf closed this Jun 12, 2024
@j-sandy j-sandy deleted the groovy-sb-2-7-18 branch June 13, 2024 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants