You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/11/15 20:24:25 UTC

[lucene-solr] branch reference_impl_dev updated (8ce4cb1 -> 0f154b9)

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

markrmiller pushed a change to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from 8ce4cb1  @1214 Tweak xml parser.
     new c217e82  @1215 Fix NPE.
     new 0f154b9  @1216 Harden - maybe finally got the no update log configured issue.

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:
 .../apache/solr/cloud/ZkSolrResourceLoader.java    |  6 ++-
 .../src/java/org/apache/solr/core/SolrCore.java    |  9 ++--
 .../org/apache/solr/core/SolrResourceLoader.java   |  2 +-
 .../java/org/apache/solr/core/XmlConfigFile.java   | 21 +++------
 .../org/apache/solr/update/SolrCmdDistributor.java |  4 +-
 .../org/apache/solr/util/SystemIdResolver.java     | 51 ++++++++++------------
 .../src/java/org/apache/solr/SolrTestCase.java     |  9 +++-
 7 files changed, 46 insertions(+), 56 deletions(-)


[lucene-solr] 01/02: @1215 Fix NPE.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit c217e828503f4f3bf9de99d1eeae88cb92ab4c19
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Sun Nov 15 13:27:06 2020 -0600

    @1215 Fix NPE.
---
 solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
index 571dd61..5fbdcd4 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
@@ -399,7 +399,7 @@ public class SolrCmdDistributor implements Closeable {
   }
 
   public static class StdNode extends Node {
-    private final ZkStateReader zkStateReader;
+    protected final ZkStateReader zkStateReader;
     protected Replica nodeProps;
     protected String collection;
     protected String shardId;
@@ -509,8 +509,6 @@ public class SolrCmdDistributor implements Closeable {
   // to try the latest leader on a fail in the case the leader just went down.
   public static class ForwardNode extends StdNode {
     
-    private ZkStateReader zkStateReader;
-    
     public ForwardNode(ZkStateReader zkStateReader, Replica nodeProps, String collection, String shardId) {
       super(zkStateReader, nodeProps, collection, shardId);
       this.collection = collection;


[lucene-solr] 02/02: @1216 Harden - maybe finally got the no update log configured issue.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 0f154b95e827e4245cdb62a4d67abcf7c559be39
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Sun Nov 15 14:24:02 2020 -0600

    @1216 Harden - maybe finally got the no update log configured issue.
---
 .../apache/solr/cloud/ZkSolrResourceLoader.java    |  6 ++-
 .../src/java/org/apache/solr/core/SolrCore.java    |  9 ++--
 .../org/apache/solr/core/SolrResourceLoader.java   |  2 +-
 .../java/org/apache/solr/core/XmlConfigFile.java   | 21 +++------
 .../org/apache/solr/util/SystemIdResolver.java     | 51 ++++++++++------------
 .../src/java/org/apache/solr/SolrTestCase.java     |  9 +++-
 6 files changed, 45 insertions(+), 53 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkSolrResourceLoader.java b/solr/core/src/java/org/apache/solr/cloud/ZkSolrResourceLoader.java
index c7b20fb..c672c18 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkSolrResourceLoader.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkSolrResourceLoader.java
@@ -69,14 +69,14 @@ public class ZkSolrResourceLoader extends SolrResourceLoader implements Resource
   public InputStream openResource(String resource) throws IOException {
     InputStream is;
     String file = (".".equals(resource)) ? configSetZkPath : configSetZkPath + "/" + resource;
-
+    if (log.isDebugEnabled()) log.debug("open resource {}", resource);
 
     try {
 
       Stat stat = new Stat();
       byte[] bytes = zkController.getZkClient().getData(file, null, stat);
       if (bytes == null) {
-
+        log.error("resource not found {}", resource);
         throw new SolrResourceNotFoundException("Can't find resource '" + resource
                 + "' in classpath or '" + configSetZkPath + "', cwd="
                 + System.getProperty("user.dir"));
@@ -86,10 +86,12 @@ public class ZkSolrResourceLoader extends SolrResourceLoader implements Resource
       ParWork.propagateInterrupt(e);
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Interrupted while opening " + file, e);
     } catch (KeeperException.NoNodeException e) {
+      log.error("resource not found {}", resource);
       throw new SolrResourceNotFoundException("Can't find resource '" + resource
               + "' in classpath or '" + configSetZkPath + "', cwd="
               + System.getProperty("user.dir"));
     } catch (KeeperException e) {
+      log.error("zookeeper exception trying to open resource {}", resource);
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error opening " + file, e);
     }
   }
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index bd22ead..06b3efe 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1078,9 +1078,6 @@ public final class SolrCore implements SolrInfoBean, Closeable {
 
       initSearcher(prev);
 
-      // Finally tell anyone who wants to know
-      resourceLoader.inform(resourceLoader);
-
       this.updateHandler.informEventListeners(this);
 
       infoRegistry.put("core", this);
@@ -1093,6 +1090,8 @@ public final class SolrCore implements SolrInfoBean, Closeable {
 
       bufferUpdatesIfConstructing(coreDescriptor);
 
+      registerConfListener();
+
       this.ruleExpiryLock = new ReentrantLock();
       this.snapshotDelLock = new ReentrantLock();
 
@@ -1104,11 +1103,11 @@ public final class SolrCore implements SolrInfoBean, Closeable {
       // from the core.
       resourceLoader.inform(infoRegistry);
 
+      // Finally tell anyone who wants to know
+      resourceLoader.inform(resourceLoader);
 
       resourceLoader.inform(this); // last call before the latch is released.
 
-      registerConfListener();
-
       searcherReadyLatch.countDown();
 
       // seed version buckets with max from index during core initialization ... requires a searcher!
diff --git a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
index be479cb..26a119d 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
@@ -175,7 +175,7 @@ public class SolrResourceLoader implements ResourceLoader, Closeable {
   }
 
   public SystemIdResolver getSysIdResolver() {
-    return  sysIdResolver;
+    return sysIdResolver;
   }
 
   /**
diff --git a/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java b/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
index b3930cb..7d0b4dc 100644
--- a/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
+++ b/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
@@ -196,27 +196,16 @@ public class XmlConfigFile { // formerly simply "Config"
 
       conf2.setDocumentNumberAllocator(conf1.getDocumentNumberAllocator());
       conf2.setNamePool(conf1.getNamePool());
-
+      conf2.setURIResolver(loader.getSysIdResolver().asURIResolver());
       PipelineConfiguration plc = conf2.makePipelineConfiguration();
-      plc.setURIResolver(loader.getSysIdResolver().asURIResolver());
-
-      ParseOptions parseOptions = conf2.getParseOptions();
-      if (is.getSystemId() != null) {
-        parseOptions.setEntityResolver(loader.getSysIdResolver());
-      }
-
-      parseOptions.setXIncludeAware(true);
-      parseOptions.setExpandAttributeDefaults(true);
-      parseOptions.setPleaseCloseAfterUse(true);
-      //        parseOptions.setSchemaValidationMode(Validation.STRIP);
-      parseOptions.setSchemaValidationMode(0);
-
-      TinyDocumentImpl docTree = null;
+      //plc.setURIResolver(loader.getSysIdResolver().asURIResolver());
+      conf2.getParseOptions().setEntityResolver(loader.getSysIdResolver());
+      TinyDocumentImpl docTree;
       SolrTinyBuilder builder = new SolrTinyBuilder(plc, substituteProps);
       try {
         //builder.setStatistics(conf2.getTreeStatistics().SOURCE_DOCUMENT_STATISTICS);
 
-        Sender.send(source, builder, parseOptions);
+        Sender.send(source, builder, conf2.getParseOptions());
         docTree = (TinyDocumentImpl) builder.getCurrentRoot();
       } finally {
         builder.close();
diff --git a/solr/core/src/java/org/apache/solr/util/SystemIdResolver.java b/solr/core/src/java/org/apache/solr/util/SystemIdResolver.java
index 64dd353..ed9ec37 100644
--- a/solr/core/src/java/org/apache/solr/util/SystemIdResolver.java
+++ b/solr/core/src/java/org/apache/solr/util/SystemIdResolver.java
@@ -17,6 +17,8 @@
 package org.apache.solr.util;
 
 import org.apache.lucene.analysis.util.ResourceLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.ext.EntityResolver2;
@@ -29,6 +31,7 @@ import javax.xml.transform.URIResolver;
 import javax.xml.transform.sax.SAXSource;
 import java.io.File;
 import java.io.IOException;
+import java.lang.invoke.MethodHandles;
 import java.net.URI;
 import java.net.URISyntaxException;
 
@@ -51,6 +54,7 @@ import java.net.URISyntaxException;
  * </pre>
  */
 public final class SystemIdResolver implements EntityResolver, EntityResolver2 {
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   public static final String RESOURCE_LOADER_URI_SCHEME = "solrres";
   public static final String RESOURCE_LOADER_AUTHORITY_ABSOLUTE = "@";
@@ -66,34 +70,29 @@ public final class SystemIdResolver implements EntityResolver, EntityResolver2 {
   }
   
   public URIResolver asURIResolver() {
-    return new URIResolver() {
-      @Override
-      public Source resolve(String href, String base) throws TransformerException {
-        try {
-          final InputSource src = SystemIdResolver.this.resolveEntity(null, null, base, href);
-          return (src == null) ? null : new SAXSource(src);
-        } catch (IOException ioe) {
-          throw new TransformerException("Cannot resolve entity", ioe);
-        }
+    return (href, base) -> {
+      try {
+        final InputSource src = SystemIdResolver.this.resolveEntity(null, null, base, href);
+        return (src == null) ? null : new SAXSource(src);
+      } catch (IOException ioe) {
+        throw new TransformerException("Cannot resolve entity", ioe);
       }
     };
   }
   
   public XMLResolver asXMLResolver() {
-    return new XMLResolver() {
-      @Override
-      public Object resolveEntity(String publicId, String systemId, String baseURI, String namespace) throws XMLStreamException {
-        try {
-          final InputSource src = SystemIdResolver.this.resolveEntity(null, publicId, baseURI, systemId);
-          return (src == null) ? null : src.getByteStream();
-        } catch (IOException ioe) {
-          throw new XMLStreamException("Cannot resolve entity", ioe);
-        }
+    return (publicId, systemId, baseURI, namespace) -> {
+      try {
+        final InputSource src = SystemIdResolver.this.resolveEntity(null, publicId, baseURI, systemId);
+        return (src == null) ? null : src.getByteStream();
+      } catch (IOException ioe) {
+        throw new XMLStreamException("Cannot resolve entity", ioe);
       }
     };
   }
   
   URI resolveRelativeURI(String baseURI, String systemId) throws URISyntaxException {
+    if (log.isDebugEnabled()) log.debug("resolve relative uri {} {}, {}, {}", baseURI, systemId);
     URI uri;
     
     // special case for backwards compatibility: if relative systemId starts with "/" (we convert that to an absolute solrres:-URI)
@@ -121,6 +120,7 @@ public final class SystemIdResolver implements EntityResolver, EntityResolver2 {
   
   @Override
   public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws IOException {
+    if (log.isDebugEnabled()) log.debug("resolve entity {} {}, {}, {}", name, publicId, baseURI, systemId);
     if (systemId == null) {
       return null;
     }
@@ -133,15 +133,10 @@ public final class SystemIdResolver implements EntityResolver, EntityResolver2 {
         if (!RESOURCE_LOADER_AUTHORITY_ABSOLUTE.equals(authority)) {
           path = path.substring(1);
         }
-        try {
-          final InputSource is = new InputSource(loader.openResource(path));
-          is.setSystemId(uri.toASCIIString());
-          is.setPublicId(publicId);
-          return is;
-        } catch (RuntimeException re) {
-          // unfortunately XInclude fallback only works with IOException, but openResource() never throws that one
-          throw new IOException(re.getMessage(), re);
-        }
+        final InputSource is = new InputSource(loader.openResource(path));
+        is.setSystemId(uri.toString());
+        is.setPublicId(publicId);
+        return is;
       } else {
         throw new IOException("Cannot resolve absolute systemIDs / external entities (only relative paths work): " + systemId);
       }
@@ -166,7 +161,7 @@ public final class SystemIdResolver implements EntityResolver, EntityResolver2 {
       name = "/" + name;
     }
     try {
-      return new URI(RESOURCE_LOADER_URI_SCHEME, authority, name, null, null).toASCIIString();
+      return new URI(RESOURCE_LOADER_URI_SCHEME, authority, name, null, null).toString();
     } catch (URISyntaxException use) {
       throw new IllegalArgumentException("Invalid syntax of Solr Resource URI", use);
     }
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
index b8e22bb..423be7a 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
@@ -67,6 +67,7 @@ import org.apache.solr.util.RevertDefaultThreadHandlerRule;
 import org.apache.solr.util.SSLTestConfig;
 import org.apache.solr.util.StartupLoggingUtils;
 import org.apache.solr.util.TestInjection;
+import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -455,8 +456,13 @@ public class SolrTestCase extends LuceneTestCase {
     throw new RuntimeException("Cannot find resource in classpath or in file-system (relative to CWD): " + name);
   }
 
+  @After
+  public void afterSolrTestCase() throws Exception {
+
+  }
+
   @AfterClass
-  public static void afterSolrTestCase() throws Exception {
+  public static void afterSolrTestCaseClass() throws Exception {
     log.info("*******************************************************************");
     log.info("@After Class ------------------------------------------------------");
     try {
@@ -513,6 +519,7 @@ public class SolrTestCase extends LuceneTestCase {
 //                  + testTime);
       }
     } finally {
+      System.clearProperty("enable.update.log");
       Class<? extends Object> clazz = null;
       Long tooLongTime = 0L;
       String times = null;