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?
After some trial and error I found here that upgrading to log4j 2.17.0 implies a new dependency log4j-web
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-web -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.17.0</version>
</dependency>
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();