You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/06/14 00:02:21 UTC

[commons-bcel] branch master updated: Use Apache Commons IO in tests

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git


The following commit(s) were added to refs/heads/master by this push:
     new 3f7a8ec8 Use Apache Commons IO in tests
3f7a8ec8 is described below

commit 3f7a8ec805b1c5a6864516c656a7775c95457238
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Tue Jun 13 20:02:16 2023 -0400

    Use Apache Commons IO in tests
---
 pom.xml                                             | 6 ++++++
 src/test/java/org/apache/bcel/generic/JavaHome.java | 9 +++------
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index d07161eb..b025be5e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -468,6 +468,12 @@
       <artifactId>commons-lang3</artifactId>
       <version>3.12.0</version>
     </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>2.13.0</version>
+      <scope>test</scope>
+    </dependency>
     <dependency>
        <!-- BCEL-336 refers to this specific version.  -->
       <groupId>javax</groupId>
diff --git a/src/test/java/org/apache/bcel/generic/JavaHome.java b/src/test/java/org/apache/bcel/generic/JavaHome.java
index d59bc2e4..7b00a6cc 100644
--- a/src/test/java/org/apache/bcel/generic/JavaHome.java
+++ b/src/test/java/org/apache/bcel/generic/JavaHome.java
@@ -39,6 +39,7 @@ import org.apache.bcel.classfile.JavaClass;
 import org.apache.bcel.classfile.Module;
 import org.apache.bcel.classfile.Utility;
 import org.apache.bcel.util.ModularRuntimeImage;
+import org.apache.commons.io.function.Uncheck;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.SystemUtils;
 
@@ -69,12 +70,8 @@ public class JavaHome {
 
     private static Stream<Path> find(final Path start, final int maxDepth, final BiPredicate<Path, BasicFileAttributes> matcher,
             final FileVisitOption... options) {
-        try {
-            // TODO Replace with Apache Commons IO UncheckedFiles later.
-            return Files.exists(start) ? Files.find(start, maxDepth, matcher, options) : Stream.empty();
-        } catch (final IOException e) {
-            throw new UncheckedIOException(e);
-        }
+        // TODO Apache Commons 2.14.0: Use FilesUncheck 
+        return Files.exists(start) ? Uncheck.apply(Files::find, start, maxDepth, matcher, options) : Stream.empty();
     }
 
     private static JavaHome from(final String javaHome) {