Thanks for the explanation, Uwe. I'll use ZkController.class.getClassLoader() here.
On Tue, Jun 27, 2017 at 6:18 PM, Uwe Schindler <u...@thetaphi.de> wrote: > Thats the change like was done before. I think this was introduced by a > merge conflict on the autoscaling branch, because I rmeoved that already: > > solr/core/src/java/org/apache/solr/cloud/ZkController.java | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > 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 f8543db..59dca12 100644 > --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java > +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java > @@ -50,7 +50,6 @@ 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; > @@ -716,10 +715,8 @@ public class ZkController { > 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); > + URL classpathUrl = ZkController.class.getClassLoader().getResource( > serverSubPath); > try { > if (classpathUrl != null && new File(classpathUrl.toURI()).exists()) > { > return new File(classpathUrl.toURI()).getAbsolutePath(); > > ----- > Uwe Schindler > Achterdiek 19, D-28357 Bremen > http://www.thetaphi.de > eMail: u...@thetaphi.de > > > -----Original Message----- > > From: Uwe Schindler [mailto:u...@thetaphi.de] > > Sent: Tuesday, June 27, 2017 2:39 PM > > To: dev@lucene.apache.org > > Subject: RE: lucene-solr:master: SOLR-10272: Fixing precommit > > > > Sorry, > > > > Why do you need the context classloader here - just adding a > > suppressforbidden is not "the right fix". You can replace this with as > simple > > ZKController.class.getClassLoader() and all is fine. There is really no > need to > > use context classloader! > > > > Please change this. See also the issue from last week that fixed this. > There > > are tons of examples, also in ZKController. > > > > Uwe > > > > ----- > > Uwe Schindler > > Achterdiek 19, D-28357 Bremen > > http://www.thetaphi.de > > eMail: u...@thetaphi.de > > > > > -----Original Message----- > > > From: is...@apache.org [mailto:is...@apache.org] > > > Sent: Tuesday, June 27, 2017 1:31 PM > > > To: comm...@lucene.apache.org > > > Subject: lucene-solr:master: SOLR-10272: Fixing precommit > > > > > > Repository: lucene-solr > > > Updated Branches: > > > refs/heads/master 54fc1ee44 -> e4d0bb7dc > > > > > > > > > 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/master > > > 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 = getDefaultConfigDirFromClasspa > th(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 { > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org > > For additional commands, e-mail: dev-h...@lucene.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org > For additional commands, e-mail: dev-h...@lucene.apache.org > >