After the version bump to log4j 2.17.0 this exception was raised during the unit tests:
java.lang.ClassNotFoundException: org.apache.logging.log4j.core.util.SetUtils
How to work around this problem?
I had asked Log4j developers what to do with this. The class is treated as internal and shall not be used.
See. https://issues.apache.org/jira/browse/LOG4J2-3309
The code which might be used to replace the class shall be more less like below (using: org.apache.commons.collections4
)
import org.apache.commons.collections4.Predicate;
import org.apache.commons.collections4.SetUtils;
// generic
Predicate<E> predicate = x -> (doSthWith(x));
final Set<E> resultSet = SetUtils.predicatedSet(setOfElements, predicate);
final String[] array = (String[]) resultSet.toArray();
// for example
Predicate<String> containsString = str -> (str.startsWith(stringToSearch));
final Set<String> resultSet = SetUtils.predicatedSet(setOfStrings, containsString);
final String[] arrayOfStrings= (String[]) resultSet.toArray();
After some trial and error I found here that upgrading to log4j 2.17.0 implies a new dependency
log4j-web