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

ChangeType leads to botched imports for nested fields #4292

Merged
merged 7 commits into from
Jul 2, 2024

Conversation

timtebeek
Copy link
Contributor

After

We continued to see issues in

I've updated the test to better replicate the issue there. With this change the test fails with left imports.

Unexpected result in "A.java":
diff --git a/A.java b/A.java
index 98d3bcb..da17811 100644
--- a/A.java
+++ b/A.java
@@ -1,6 +1,8 @@ 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
 
 import static com.fasterxml.jackson.databind.SerializationFeature.WRAP_ROOT_VALUE;
+import static org.codehaus.jackson.map.SerializationConfig.SerializationFeature.WRAP_ROOT_VALUE;
 
 class A {
     void test() {

@timtebeek timtebeek self-assigned this Jun 27, 2024
@timtebeek timtebeek added the bug Something isn't working label Jun 27, 2024
@timtebeek
Copy link
Contributor Author

@sambsnyd if you're up for a puzzle, here's that updated test. I didn't yet get into looking why this now happens

@timtebeek timtebeek changed the title Better replicate the Codehaus to Jackson migration issue ChangeType leads to botched imports for nested fields Jun 28, 2024
@openrewrite openrewrite deleted a comment from github-actions bot Jul 1, 2024
@timtebeek
Copy link
Contributor Author

This comparison fails

if (maybeClass.toString().equals(oldType.getClassName())) {

For this test
void changeInnerClassToOuterClass() {
rewriteRun(
spec -> spec.recipe(new ChangeType("java.util.Map$Entry", "java.util.List", true)),

Because everything up to java. is a J.FieldAccess, all of it ending up in maybeClass, whereas that should only contain the simple class name.
image

@timtebeek timtebeek requested a review from sambsnyd July 2, 2024 20:46
@timtebeek timtebeek marked this pull request as ready for review July 2, 2024 20:47
@sambsnyd sambsnyd merged commit 145ff7b into main Jul 2, 2024
2 checks passed
@sambsnyd sambsnyd deleted the better-replicate-codehaus-jackson-issue branch July 2, 2024 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants