You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/10/29 17:56:39 UTC

[GitHub] [solr] madrob commented on a change in pull request #340: SOLR-15591 / Avoid needless catch by checking condition

madrob commented on a change in pull request #340:
URL: https://github.com/apache/solr/pull/340#discussion_r739428642



##########
File path: solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java
##########
@@ -58,21 +58,23 @@
   static String determineSourceHome() {
     try {
       File file;
-      try {
-        file = new File("solr/conf");
-        if (!file.exists()) {
-          file = new File(ExternalPaths.class.getClassLoader().getResource("solr/conf").toURI());
+
+      file = new File("solr/conf");

Review comment:
       nit: this can be combined with the declaration on line 60.

##########
File path: solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java
##########
@@ -58,21 +58,23 @@
   static String determineSourceHome() {
     try {
       File file;
-      try {
-        file = new File("solr/conf");
-        if (!file.exists()) {
-          file = new File(ExternalPaths.class.getClassLoader().getResource("solr/conf").toURI());
+
+      file = new File("solr/conf");
+      if (!file.exists()) {
+        URL resourceUrl = ExternalPaths.class.getClassLoader().getResource("solr/conf");
+        if(resourceUrl != null) {
+          file = new File(resourceUrl.toURI());
+        } else {
+          file = new File(System.getProperty("tests.src.home", "."));
         }
-      } catch (Exception e) {
-        // If there is no "solr/conf" in the classpath, fall back to searching from the current directory.

Review comment:
       we should keep this comment




-- 
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-unsubscribe@solr.apache.org

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



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