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

Unable to detect type of chain method invocation #4775

Open
SiBorya opened this issue Dec 12, 2024 · 3 comments
Open

Unable to detect type of chain method invocation #4775

SiBorya opened this issue Dec 12, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@SiBorya
Copy link

SiBorya commented Dec 12, 2024

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.41.1

What is the smallest, simplest way to reproduce the problem?

For ObjectClassA.methodX().methodY()

  • methodX() return ObjectClassA
  • methodY() doesn't exist in ClassB

After changing ObjectClassA to ObjectClassB, OpenRewrite can't detect the methodType of methodY() (the pattern should be ClassB methodY()

I suppose the issue is related to line 462
image

Here the code snippet you may need in my case (from httpclient4 to httpclient5):

HttpClientBuilder.create()
        .setDefaultRequestConfig(config)
        .setSSLSocketFactory(sslSocketFactory)
@SiBorya SiBorya added the bug Something isn't working label Dec 12, 2024
@timtebeek
Copy link
Contributor

hi @SiBorya ; would you mind elaborating a bit if this is already part way through a migration or not? Wondering if this is an issue with parsing the Apache HttpClient 4 code at all, or when there have already been a number of ChangeType recipe invocations.

@SiBorea
Copy link
Contributor

SiBorea commented Dec 16, 2024

It's not only the issue on HttpClient4. My colleague encountered this one in SpringBatch too. I suppose it's a common issue.

My recipe is pretty complex and can't tell more details. But probably a ChangeType can trigger this issue. I may write a full test code later.

@SiBorya
Copy link
Author

SiBorya commented Dec 27, 2024

After debug, I suppose using JavaTemplate will trigger OpenRewrite to parse types again.
For example, a method contains 4 lines of code. Recipe A changes line 1 and the dependency using JavaTemplate. Before sending to Recipe B, it will parse the method and find line 3 "Unknown" because of dependency changed.

Is it how OpenRewrite work? @timtebeek

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
Status: No status
Development

No branches or pull requests

3 participants