-
Notifications
You must be signed in to change notification settings - Fork 110
Closed
Labels
Description
- This issue follows the issue
Sets.newHashSet(Iterables.filter...is not correctly handed by NoGuavaSetsNewHashSet recipe #881. ThePredicateclass from Guava is converted injava.util.Predicateeven when it is used in aIterables.filtermethod that is not converted.
As a result, the following error appears after migration:The method filter(Iterable<T>, Predicate<? super T>) in the type Iterables is not applicable for the arguments (List<Exception>, Predicate<Exception>).
I reproduced the issue with the simple class below.
What version of OpenRewrite are you using?
I am using
- OpenRewrite v6.21.1
- Maven v3.9.5
- org.openrewrite.recipe:rewrite-migrate-java v3.19.0
How are you running OpenRewrite?
I used the Maven command line to launch the recipe on the Sirius Desktop repository :
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE -Drewrite.activeRecipes=org.openrewrite.java.migrate.guava.NoGuavaSetsNewHashSet -Drewrite.exportDatatables=true -f packaging/org.eclipse.sirius.parent/pom.xmlWhat is the smallest, simplest way to reproduce the problem?
import java.util.ArrayList;
import java.util.List;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
class Test {
public static void test() {
List<Exception> myExceptions = new ArrayList<Exception>();
Predicate<Exception> isTrue = new Predicate<Exception>() {
@Override
public boolean apply(Exception input) {
return false;
}
};
Iterable<Exception> iterable = Iterables.filter(myExceptions, isTrue);
}
}What did you expect to see?
As long as Iterables.filter(Iterable<T> unfiltered, com.google.common.base.Predicat) is not migrated, I believe that the original code should be preserved as-is.
What did you see instead?
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import com.google.common.collect.Iterables;
class Test {
public static void test() {
List<Exception> myExceptions = new ArrayList<Exception>();
Predicate<Exception> isTrue = new Predicate<Exception>() {
@Override
public boolean test(Exception input) {
return false;
}
};
Iterable<Exception> iterable = Iterables.filter(myExceptions, isTrue);
}
}Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done