You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2017/06/28 06:51:41 UTC
[02/18] lucene-solr:feature/autoscaling: SOLR-10272: Fixing precommit
SOLR-10272: Fixing precommit
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e4d0bb7d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e4d0bb7d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e4d0bb7d
Branch: refs/heads/feature/autoscaling
Commit: e4d0bb7dc45905b6ab231b940adecd5c5a39eb8e
Parents: 54fc1ee
Author: Ishan Chattopadhyaya <is...@apache.org>
Authored: Tue Jun 27 17:01:01 2017 +0530
Committer: Ishan Chattopadhyaya <is...@apache.org>
Committed: Tue Jun 27 17:01:01 2017 +0530
----------------------------------------------------------------------
.../org/apache/solr/cloud/ZkController.java | 22 +++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e4d0bb7d/solr/core/src/java/org/apache/solr/cloud/ZkController.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index 391f29c..f8543db 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -50,6 +50,7 @@ import java.util.concurrent.atomic.AtomicReference;
import com.google.common.base.Strings;
import org.apache.commons.lang.StringUtils;
+import org.apache.lucene.util.SuppressForbidden;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient.Builder;
import org.apache.solr.client.solrj.request.CoreAdminRequest.WaitForState;
@@ -695,7 +696,7 @@ public class ZkController {
* Gets the absolute filesystem path of the _default configset to bootstrap from.
* First tries the sysprop "solr.default.confdir". If not found, tries to find
* the _default dir relative to the sysprop "solr.install.dir".
- * If that fails as well, tries to get the _default from the
+ * If that fails as well (usually for unit tests), tries to get the _default from the
* classpath. Returns null if not found anywhere.
*/
private static String getDefaultConfigDirPath() {
@@ -710,16 +711,23 @@ public class ZkController {
new File(System.getProperty(SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE) + subPath).exists()) {
configDirPath = new File(System.getProperty(SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE) + subPath).getAbsolutePath();
} else { // find "_default" in the classpath. This one is used for tests
- URL classpathUrl = Thread.currentThread().getContextClassLoader().getResource(serverSubPath);
- try {
- if (classpathUrl != null && new File(classpathUrl.toURI()).exists()) {
- configDirPath = new File(classpathUrl.toURI()).getAbsolutePath();
- }
- } catch (URISyntaxException ex) {}
+ configDirPath = getDefaultConfigDirFromClasspath(serverSubPath);
}
return configDirPath;
}
+ @SuppressForbidden(reason = "This will be loaded for unit tests, and hence an exception can be made. "
+ + "In regular server operation, there shouldn't be a situation where we reach this point.")
+ private static String getDefaultConfigDirFromClasspath(String serverSubPath) {
+ URL classpathUrl = Thread.currentThread().getContextClassLoader().getResource(serverSubPath);
+ try {
+ if (classpathUrl != null && new File(classpathUrl.toURI()).exists()) {
+ return new File(classpathUrl.toURI()).getAbsolutePath();
+ }
+ } catch (URISyntaxException ex) {}
+ return null;
+ }
+
private void init(CurrentCoreDescriptorProvider registerOnReconnect) {
try {