mlbiscoc commented on code in PR #3263:
URL: https://github.com/apache/solr/pull/3263#discussion_r1998742643


##########
solr/core/src/test/org/apache/solr/SolrInfoBeanTest.java:
##########
@@ -88,30 +90,37 @@ public void testCallMBeanInfo() throws Exception {
   }
 
   private static List<Class<?>> getClassesForPackage(String pckgname) throws 
Exception {
-    ArrayList<File> directories = new ArrayList<>();
+    ArrayList<Path> directories = new ArrayList<>();
     ClassLoader cld = h.getCore().getResourceLoader().getClassLoader();
     String path = pckgname.replace('.', '/');
     Enumeration<URL> resources = cld.getResources(path);
     while (resources.hasMoreElements()) {
       final URI uri = resources.nextElement().toURI();
       if (!"file".equalsIgnoreCase(uri.getScheme())) continue;
-      final File f = new File(uri);
+      final Path f = Path.of(uri);
       directories.add(f);
     }
 
     ArrayList<Class<?>> classes = new ArrayList<>();
-    for (File directory : directories) {
-      if (directory.exists()) {
-        String[] files = directory.list();
-        for (String file : files) {
-          if (file.endsWith(".class")) {
-            String clazzName = file.substring(0, file.length() - 6);
-            // exclude Test classes that happen to be in these packages.
-            // class.ForName'ing some of them can cause trouble.
-            if (!clazzName.endsWith("Test") && !clazzName.startsWith("Test")) {
-              classes.add(Class.forName(pckgname + '.' + clazzName));
-            }
-          }
+    for (Path directory : directories) {
+      if (Files.exists(directory)) {
+        try (Stream<Path> files = Files.list(directory)) {

Review Comment:
   The Path equivalent for `directory.list();` in path is `Files.list` but this 
requires a try-with-resources since it returns a stream and  closes the stream 
at the end. Other option is removing the try with resources but we need to call 
a `.close()` to close it manually.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to