openrewrite / rewrite-migrate-java

OpenRewrite recipes for migrating to newer versions of Java.
Apache License 2.0
111 stars 75 forks source link

UpdateBeanManagerMethods refactors `fireEvent(event, qualifier)` incorrectly #597

Closed cortlepp closed 2 weeks ago

cortlepp commented 3 weeks ago

What version of OpenRewrite are you using?

I am using

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a multi module project, but I ran the recipe for each module individually.

    <plugin>
        <groupId>org.openrewrite.maven</groupId>
        <artifactId>rewrite-maven-plugin</artifactId>
        <version>5.43.4</version>
        <configuration>
            <activeRecipes>
                <recipe>org.openrewrite.java.migrate.jakarta.UpdateBeanManagerMethods</recipe>
            </activeRecipes>
            <skipMavenParsing>true</skipMavenParsing>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>org.openrewrite.recipe</groupId>
                <artifactId>rewrite-migrate-java</artifactId>
                <version>2.28.0</version>
            </dependency>
        </dependencies>
    </plugin>

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

class A {
    void foo(Object event, Annotation qualifier) {
        CDI.current().getBeanManager().fireEvent(object, qualifier);
    }
}

What did you expect to see?

class A {
    void foo(Object event, Annotation qualifier) {
        CDI.current().getBeanManager().select(qualifier).fire(object);
    }
}

What did you see instead?

class A {
    void foo(Object event, Annotation qualifier) {
        CDI.current().getBeanManager().fire(object);
    }
}

What is the full stack trace of any errors you encountered?

There were no errors, it just silently omitted the qualifier.

Are you interested in contributing a fix to OpenRewrite?

Depends on the effort that is required, but generally yes.

timtebeek commented 2 weeks ago

Thanks for the report @cortlepp ! Had no idea about those extra parameters. Fixed now in