[cxf] branch master updated (c8683be -> 57025af)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[cxf] branch master updated (c8683be -> 57025af)

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

coheigea pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from c8683be  Simplify FileUtils.readLines
     new 33c46b8  Refactor FileUtils to use a suffix instead of a reg ex
     new 57025af  Make StringUtils.getFirstFound more efficient

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/cxf/common/util/StringUtils.java    | 22 +++-------
 .../java/org/apache/cxf/helpers/FileUtils.java     | 47 +++++++++++---------
 .../apache/cxf/common/util/StringUtilsTest.java    |  8 ++--
 .../java/org/apache/cxf/helpers/FileUtilsTest.java | 17 ++++++++
 .../cxf/endpoint/dynamic/DynamicClientFactory.java |  2 +-
 .../org/apache/cxf/tools/common/ClassUtils.java    |  6 +--
 .../cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java | 50 +++++++++++-----------
 .../cxf/tools/wadlto/jaxrs/WADLToJavaTest.java     |  2 +-
 8 files changed, 82 insertions(+), 72 deletions(-)

Reply | Threaded
Open this post in threaded view
|

[cxf] 01/02: Refactor FileUtils to use a suffix instead of a reg ex

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

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 33c46b89a4f6832af102ed66b57623b392ce0007
Author: Colm O hEigeartaigh <[hidden email]>
AuthorDate: Thu Jan 10 16:39:53 2019 +0000

    Refactor FileUtils to use a suffix instead of a reg ex
---
 .../java/org/apache/cxf/helpers/FileUtils.java     | 47 +++++++++++---------
 .../java/org/apache/cxf/helpers/FileUtilsTest.java | 17 ++++++++
 .../cxf/endpoint/dynamic/DynamicClientFactory.java |  2 +-
 .../org/apache/cxf/tools/common/ClassUtils.java    |  6 +--
 .../cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java | 50 +++++++++++-----------
 .../cxf/tools/wadlto/jaxrs/WADLToJavaTest.java     |  2 +-
 6 files changed, 72 insertions(+), 52 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
index f8dfd9a..42b59c2 100644
--- a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
@@ -363,34 +363,24 @@ public final class FileUtils {
         return rtn;
     }
 
-    public static List<File> getFiles(File dir, final String pattern) {
-        return getFiles(dir, pattern, null);
-    }
-    public static List<File> getFilesRecurse(File dir, final String pattern) {
-        return getFilesRecurse(dir, pattern, null);
+    public static List<File> getFilesUsingSuffix(File dir, final String suffix) {
+        return getFilesRecurseUsingSuffix(dir, suffix, false, new ArrayList<>());
     }
 
-    public static List<File> getFiles(File dir, final String pattern, File exclude) {
-        return getFilesRecurse(dir, Pattern.compile(pattern), exclude, false, new ArrayList<>());
+    public static List<File> getFilesRecurseUsingSuffix(File dir, final String suffix) {
+        return getFilesRecurseUsingSuffix(dir, suffix, true, new ArrayList<>());
     }
-    public static List<File> getFilesRecurse(File dir, final String pattern, File exclude) {
-        return getFilesRecurse(dir, Pattern.compile(pattern), exclude, true, new ArrayList<>());
-    }
-    private static List<File> getFilesRecurse(File dir,
-                                              Pattern pattern,
-                                              File exclude, boolean rec,
-                                              List<File> fileList) {
+
+    private static List<File> getFilesRecurseUsingSuffix(File dir, final String suffix,
+                                                        boolean rec, List<File> fileList) {
         File[] files = dir.listFiles();
         if (files != null) {
-            for (File file : dir.listFiles()) {
-                if (file.equals(exclude)) {
-                    continue;
-                }
+            int suffixLength = suffix.length();
+            for (File file : files) {
                 if (file.isDirectory() && rec) {
-                    getFilesRecurse(file, pattern, exclude, rec, fileList);
+                    getFilesRecurseUsingSuffix(file, suffix, rec, fileList);
                 } else {
-                    Matcher m = pattern.matcher(file.getName());
-                    if (m.matches()) {
+                    if (file.getName().endsWith(suffix) && file.getName().length() > suffixLength) {
                         fileList.add(file);
                     }
                 }
@@ -399,6 +389,21 @@ public final class FileUtils {
         return fileList;
     }
 
+    public static List<File> getFiles(File dir, final String pattern) {
+        List<File> fileList = new ArrayList<>();
+        File[] files = dir.listFiles();
+        if (files != null) {
+            Pattern p = Pattern.compile(pattern);
+            for (File file : files) {
+                Matcher m = p.matcher(file.getName());
+                if (m.matches()) {
+                    fileList.add(file);
+                }
+            }
+        }
+        return fileList;
+    }
+
     public static List<String> readLines(File file) throws Exception {
         if (!file.exists()) {
             return Collections.emptyList();
diff --git a/core/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java b/core/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java
index a4a1751..db6bfd6 100644
--- a/core/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java
@@ -19,6 +19,8 @@
 package org.apache.cxf.helpers;
 
 import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -27,6 +29,7 @@ import java.util.Optional;
 
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 public class FileUtilsTest {
@@ -61,4 +64,18 @@ public class FileUtilsTest {
         List<String> lines = FileUtils.readLines(p.get().toFile());
         assertTrue(!lines.isEmpty());
     }
+
+    @Test
+    public void testGetFiles() throws URISyntaxException {
+        URL resource = FileUtilsTest.class.getResource("FileUtilsTest.class");
+        File directory = Paths.get(resource.toURI()).getParent().toFile();
+        assertTrue(directory.exists());
+
+        List<File> foundFiles = FileUtils.getFilesUsingSuffix(directory, ".class");
+        assertTrue(foundFiles.size() > 0);
+
+        List<File> foundFiles2 = FileUtils.getFiles(directory, ".*\\.class$");
+
+        assertEquals(foundFiles, foundFiles2);
+    }
 }
\ No newline at end of file
diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java b/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
index 8648c32..ba5356c 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
@@ -385,7 +385,7 @@ public class DynamicClientFactory {
             throw new RuntimeException(ex);
         }
 
-        List<File> srcFiles = FileUtils.getFilesRecurse(src, ".+\\.java$");
+        List<File> srcFiles = FileUtils.getFilesRecurseUsingSuffix(src, ".java");
         if (!srcFiles.isEmpty() && !compileJavaSrc(classPath.toString(), srcFiles, classes.toString())) {
             LOG.log(Level.SEVERE, new Message("COULD_NOT_COMPILE_SRC", LOG, wsdlUrl).toString());
         }
diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java b/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
index 4ea2c6f..4810615 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
+++ b/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java
@@ -110,10 +110,8 @@ public class ClassUtils {
                     // Those files can not be allocated into the ClassCollector
                     File jaxbRuntime = new File(path, "runtime");
                     if (jaxbRuntime.isDirectory() && jaxbRuntime.exists()) {
-                        List<File> files = FileUtils.getFiles(jaxbRuntime, ".+\\.java$");
-                        for (File f : files) {
-                            fileList.add(f.toString());
-                        }
+                        List<File> files = FileUtils.getFilesUsingSuffix(jaxbRuntime, ".java");
+                        files.forEach(f -> fileList.add(f.toString()));
                     }
                 }
             }
diff --git a/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java b/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
index 592b856..f948a48 100644
--- a/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
+++ b/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
@@ -71,7 +71,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
         container.execute();
 
         assertNotNull(output.list());
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\.class" + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(3, files.size());
         assertTrue(checkContains(files, "application" + ".Resource.class"));
         assertTrue(checkContains(files, "custom" + ".TestCompositeObject.class"));
@@ -121,7 +121,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(1, files.size());
     }
 
@@ -165,7 +165,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> javaFiles = FileUtils.getFilesRecurse(output, ".+\\." + "java" + "$");
+        List<File> javaFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
         assertEquals(2, javaFiles.size());
         for (File f : javaFiles) {
             if (!f.getName().endsWith("Impl.java")) {
@@ -187,7 +187,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
             for (String className : cc.getServiceClassNames().values()) {
                 final Class<?> generatedClass = loader.loadClass(className);
                 for (Map.Entry<String, Class<?>[]> entry : methods.entrySet()) {
-                    Method m;
+                    Method m;
                     try {
                         m = generatedClass.getMethod(entry.getKey(), String.class);
                     } catch (NoSuchMethodException e) {
@@ -252,11 +252,11 @@ public class JAXRSContainerTest extends ProcessorTestBase {
         container.execute();
 
         assertNotNull(output.list());
-        List<File> schemafiles = FileUtils.getFilesRecurse(output, ".+\\." + "java" + "$");
+        List<File> schemafiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
         assertEquals(10, schemafiles.size());
         doVerifyTypesWithSuffix(schemafiles, "superbooks", "java");
-        
-        List<File> classfiles = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+
+        List<File> classfiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(10, classfiles.size());
         doVerifyTypesWithSuffix(classfiles, "superbooks", "class");
     }
@@ -320,7 +320,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(8, files.size());
         assertTrue(checkContains(files, "org.apache.cxf.jaxrs.model.wadl" + ".BookStore.class"));
         assertTrue(checkContains(files, "org.apache.cxf.jaxrs.model.wadl" + ".PATCH.class"));
@@ -348,7 +348,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(4, files.size());
         assertTrue(checkContains(files, "application" + ".BookstoreResource.class"));
         assertTrue(checkContains(files, "superbooks" + ".Book.class"));
@@ -376,7 +376,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(1, files.size());
         assertTrue(checkContains(files, "application" + ".BookstoreResource.class"));
     }
@@ -395,7 +395,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(2, files.size());
         assertTrue(checkContains(files, "application.Test1.class"));
         assertTrue(checkContains(files, "application.Test2.class"));
@@ -470,7 +470,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(1, files.size());
         assertTrue(checkContains(files, "application.Resource.class"));
         @SuppressWarnings("resource")
@@ -519,7 +519,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(4, files.size());
         assertTrue(checkContains(files, "application.Resource.class"));
         @SuppressWarnings("resource")
@@ -620,12 +620,12 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> javaFiles = FileUtils.getFilesRecurse(output, ".+\\." + "java" + "$");
+        List<File> javaFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
         assertEquals(2, javaFiles.size());
         assertTrue(checkContains(javaFiles, "application.CustomResource.java"));
         assertTrue(checkContains(javaFiles, "application.Theid.java"));
 
-        List<File> classFiles = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> classFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(2, classFiles.size());
         assertTrue(checkContains(classFiles, "application.CustomResource.class"));
         assertTrue(checkContains(classFiles, "application.Theid.class"));
@@ -645,11 +645,11 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> javaFiles = FileUtils.getFilesRecurse(output, ".+\\." + "java" + "$");
+        List<File> javaFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
         assertEquals(2, javaFiles.size());
         assertTrue(checkContains(javaFiles, "application.BookstoreResource.java"));
         assertTrue(checkContains(javaFiles, "application.BooksResource.java"));
-        List<File> classFiles = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> classFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(2, classFiles.size());
         assertTrue(checkContains(classFiles, "application.BookstoreResource.class"));
         assertTrue(checkContains(classFiles, "application.BooksResource.class"));
@@ -670,10 +670,10 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> javaFiles = FileUtils.getFilesRecurse(output, ".+\\." + "java" + "$");
+        List<File> javaFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
         assertEquals(1, javaFiles.size());
         assertTrue(checkContains(javaFiles, "application.TestRsResource.java"));
-        List<File> classFiles = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> classFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(1, classFiles.size());
         assertTrue(checkContains(classFiles, "application.TestRsResource.class"));
     }
@@ -690,13 +690,13 @@ public class JAXRSContainerTest extends ProcessorTestBase {
         container.setContext(context);
         container.execute();
 
-        List<File> javaFiles = FileUtils.getFilesRecurse(output, ".+\\." + "java" + "$");
+        List<File> javaFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
         assertEquals(4, javaFiles.size());
         assertTrue(checkContains(javaFiles, "application.Resource.java"));
         assertTrue(checkContains(javaFiles, "com.example.test.ObjectFactory.java"));
         assertTrue(checkContains(javaFiles, "com.example.test.package-info.java"));
         assertTrue(checkContains(javaFiles, "com.example.test.TestCompositeObject.java"));
-        List<File> classFiles = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> classFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(4, classFiles.size());
         assertTrue(checkContains(classFiles, "application.Resource.class"));
         assertTrue(checkContains(classFiles, "com.example.test.ObjectFactory.class"));
@@ -722,11 +722,11 @@ public class JAXRSContainerTest extends ProcessorTestBase {
 
         assertNotNull(output.list());
 
-        List<File> javaFiles = FileUtils.getFilesRecurse(output, ".+\\." + "java" + "$");
+        List<File> javaFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".java");
         assertEquals(1, javaFiles.size());
         assertTrue(checkContains(javaFiles, "application.CustomResource.java"));
 
-        List<File> classFiles = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+        List<File> classFiles = FileUtils.getFilesRecurseUsingSuffix(output, ".class");
         assertEquals(1, classFiles.size());
         assertTrue(checkContains(classFiles, "application.CustomResource.class"));
     }
@@ -835,7 +835,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
     private void verifyFiles(String ext, boolean subresourceExpected, boolean interfacesAndImpl,
                              String schemaPackage, String resourcePackage, int expectedCount,
                              boolean enumTypeExpected) {
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + ext + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, "." + ext);
         int offset = enumTypeExpected ? 1 : 2;
         int size = interfacesAndImpl ? expectedCount : expectedCount - offset;
         if (!subresourceExpected) {
@@ -858,7 +858,7 @@ public class JAXRSContainerTest extends ProcessorTestBase {
     }
 
     private void verifyTypes(String schemaPackage, String ext, boolean enumTypeExpected) {
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + ext + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, "." + ext);
         assertEquals(enumTypeExpected ? 6 : 5, files.size());
         doVerifyTypes(files, schemaPackage, ext);
     }
diff --git a/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java b/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
index 25ab820..566ff01 100644
--- a/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
+++ b/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
@@ -135,7 +135,7 @@ public class WADLToJavaTest extends ProcessorTestBase {
 
     private void verifyFiles(String ext, boolean subresourceExpected, boolean interfacesAndImpl,
                              String schemaPackage, String resourcePackage) {
-        List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + ext + "$");
+        List<File> files = FileUtils.getFilesRecurseUsingSuffix(output, "." + ext);
         int size = interfacesAndImpl ? 11 : 10;
         if (!subresourceExpected) {
             size--;

Reply | Threaded
Open this post in threaded view
|

[cxf] 02/02: Make StringUtils.getFirstFound more efficient

coheigea
Administrator
In reply to this post by coheigea
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 57025af84e7fd41e3a0832385adce91c086957e3
Author: Colm O hEigeartaigh <[hidden email]>
AuthorDate: Thu Jan 10 16:40:41 2019 +0000

    Make StringUtils.getFirstFound more efficient
---
 .../org/apache/cxf/common/util/StringUtils.java    | 22 ++++++----------------
 .../apache/cxf/common/util/StringUtilsTest.java    |  8 ++++----
 2 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/common/util/StringUtils.java b/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
index c06db7b..48244f5 100644
--- a/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
@@ -24,7 +24,6 @@ import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.function.Predicate;
 import java.util.regex.Matcher;
@@ -52,7 +51,7 @@ public final class StringUtils {
         }
         return true;
     }
-    
+
     public static Predicate<String> notEmpty() {
         return NOT_EMPTY;
     }
@@ -72,30 +71,21 @@ public final class StringUtils {
         return str1;
     }
 
-    public static List<String> getFound(String contents, String regex) {
+    public static String getFirstFound(String contents, String regex) {
         if (isEmpty(regex) || isEmpty(contents)) {
             return null;
         }
-        List<String> results = new ArrayList<>();
         Pattern pattern = Pattern.compile(regex, Pattern.UNICODE_CASE);
         Matcher matcher = pattern.matcher(contents);
 
-        while (matcher.find()) {
+        if (matcher.find()) {
             if (matcher.groupCount() > 0) {
-                results.add(matcher.group(1));
+                return matcher.group(1);
             } else {
-                results.add(matcher.group());
+                return matcher.group();
             }
         }
-        return results;
-    }
-
-    public static String getFirstFound(String contents, String regex) {
-        List<String> founds = getFound(contents, regex);
-        if (isEmpty(founds)) {
-            return null;
-        }
-        return founds.get(0);
+        return null;
     }
 
     public static String addDefaultPortIfMissing(String urlString) {
diff --git a/core/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java b/core/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java
index 5c4e452..689f51b 100644
--- a/core/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java
@@ -38,12 +38,12 @@ public class StringUtilsTest {
     }
 
     @Test
-    public void testGetFound() throws Exception {
+    public void testGetFirstFound() throws Exception {
         String regex = "velocity-\\d+\\.\\d+\\.jar";
 
-        assertTrue(StringUtils.isEmpty(StringUtils.getFound("velocity-dep-1.4.jar", regex)));
-        assertFalse(StringUtils.isEmpty(StringUtils.getFound("velocity-1.4.jar", regex)));
-        assertTrue(StringUtils.isEmpty(StringUtils.getFound(null, regex)));
+        assertTrue(StringUtils.isEmpty(StringUtils.getFirstFound("velocity-dep-1.4.jar", regex)));
+        assertFalse(StringUtils.isEmpty(StringUtils.getFirstFound("velocity-1.4.jar", regex)));
+        assertTrue(StringUtils.isEmpty(StringUtils.getFirstFound(null, regex)));
     }
 
     @Test