Open timbuethe opened 2 weeks ago
Thanks a lot for reducing the issue you had down to a runnable unit test! Should help in debugging this; I suspect it's something to do with transitive dependencies, seeing how the behavior changes with or without Mockito if I understood #537 correctly. As a quick first step we might see if pull forward, or pushing backwards in recipe order any Mockito upgrade might already provide relief. 🤔
Might take me a bit of time to dive into this one in detail, but let me know if you've learned anything from running this test already.
Thanks again @timbuethe ; I've tried it out locally as we've just had some changes upstream in openrewrite/rewrite. I had to apply some small formatting fixes to your test, and make it expect two cycles of changes (that one's questionable), but with these the test passes locally.
diff --git a/src/testWithSpringBoot_3_3/java/org/openrewrite/java/spring/boot3/SpringCloudVersionUpgradeTest.java b/src/testWithSpringBoot_3_3/java/org/openrewrite/java/spring/boot3/SpringCloudVersionUpgradeTest.java
index aac5066..dcd0f05 100644
--- a/src/testWithSpringBoot_3_3/java/org/openrewrite/java/spring/boot3/SpringCloudVersionUpgradeTest.java
+++ b/src/testWithSpringBoot_3_3/java/org/openrewrite/java/spring/boot3/SpringCloudVersionUpgradeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2023 the original author or authors.
+ * Copyright 2024 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,16 +26,16 @@ import static org.openrewrite.maven.Assertions.pomXml;
class SpringCloudVersionUpgradeTest implements RewriteTest {
-
@Override
public void defaults(RecipeSpec spec) {
spec
+ .expectedCyclesThatMakeChanges(2)
.recipe(Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.spring")
.build()
.activateRecipes("org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3")
).parser(JavaParser.fromJavaVersion()
- .classpath( "jaxb-api"));
+ .classpath("jaxb-api"));
}
@Test
@@ -45,82 +45,81 @@ class SpringCloudVersionUpgradeTest implements RewriteTest {
//language=xml
pomXml(
"""
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <groupId>com.example</groupId>
- <artifactId>fooservice</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <groupId>com.example</groupId>
+ <artifactId>fooservice</artifactId>
+ <version>1.0-SNAPSHOT</version>
- <name>FooService</name>
+ <name>FooService</name>
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>2.2.2.RELEASE</version>
- <relativePath/>
- </parent>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>2.2.2.RELEASE</version>
+ <relativePath/>
+ </parent>
- <properties>
- <java.version>11</java.version>
- <spring-cloud.version>Hoxton.SR9</spring-cloud.version>
- <mockito.version>2.18.3</mockito.version>
- </properties>
+ <properties>
+ <java.version>11</java.version>
+ <spring-cloud.version>Hoxton.SR9</spring-cloud.version>
+ <mockito.version>2.18.3</mockito.version>
+ </properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-dependencies</artifactId>
- <version>${spring-cloud.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-dependencies</artifactId>
+ <version>${spring-cloud.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
</project>
""",
"""
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <groupId>com.example</groupId>
- <artifactId>fooservice</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <groupId>com.example</groupId>
+ <artifactId>fooservice</artifactId>
+ <version>1.0-SNAPSHOT</version>
- <name>FooService</name>
+ <name>FooService</name>
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>3.3.0</version>
- <relativePath/>
- </parent>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>3.3.1</version>
+ <relativePath/>
+ </parent>
- <properties>
+ <properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.2</spring-cloud.version>
<mockito.version>2.18.3</mockito.version>
- </properties>
+ </properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-dependencies</artifactId>
- <version>${spring-cloud.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-dependencies</artifactId>
+ <version>${spring-cloud.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
</project>
"""
)
)
);
}
-
}
I could not push these changes up to freenowtech:537-upgradespringboot_3_3-setting-wrong-spring-cloud-version
, which makes it somewhat harder to polish this test addition for adoption. Are you already seeing improvements locally when you use
our snapshot versions?
Hey @timtebeek, thanks for your time an effort. I applied your patch and merged latest changes to the branch. If you want to make more changes, feel free to copy the file or branch to your repository. I will try the snapshot version and report back.
What's changed?
What's your motivation?
This should reproduce issue #537
Any additional context