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

dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 6ea51f7  SOLR-15258: ConfigSetService operations ought to throw 
IOException (#221)
6ea51f7 is described below

commit 6ea51f791d7babbed9fea4916797b1a0797f5b56
Author: Nazerke Seidan <[email protected]>
AuthorDate: Mon Jan 10 21:12:02 2022 +0100

    SOLR-15258: ConfigSetService operations ought to throw IOException (#221)
    
    Co-authored-by: Nazerke Seidan <[email protected]>
---
 .../java/org/apache/solr/cloud/ZkConfigSetService.java   |  4 ++--
 .../src/java/org/apache/solr/core/ConfigSetService.java  | 16 +++++++++++-----
 .../org/apache/solr/core/FileSystemConfigSetService.java |  2 +-
 .../src/test/org/apache/solr/core/TestCoreContainer.java |  2 +-
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java 
b/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java
index 604b9cc..21a8b80 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkConfigSetService.java
@@ -101,7 +101,7 @@ public class ZkConfigSetService extends ConfigSetService {
   }
 
   @Override
-  protected NamedList<Object> loadConfigSetFlags(CoreDescriptor cd, 
SolrResourceLoader loader) {
+  protected NamedList<Object> loadConfigSetFlags(CoreDescriptor cd, 
SolrResourceLoader loader) throws IOException {
     try {
       return ConfigSetProperties.readFromResourceLoader(loader, ".");
     } catch (Exception ex) {
@@ -111,7 +111,7 @@ public class ZkConfigSetService extends ConfigSetService {
   }
 
   @Override
-  protected Long getCurrentSchemaModificationVersion(String configSet, 
SolrConfig solrConfig, String schemaFile) {
+  protected Long getCurrentSchemaModificationVersion(String configSet, 
SolrConfig solrConfig, String schemaFile) throws IOException {
     String zkPath = CONFIGS_ZKNODE + "/" + configSet + "/" + schemaFile;
     Stat stat;
     try {
diff --git a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java 
b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
index abab0f1..73e3f20 100644
--- a/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
+++ b/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
@@ -244,7 +244,13 @@ public abstract class ConfigSetService {
               ) ? false: true;
 
       SolrConfig solrConfig = createSolrConfig(dcore, coreLoader, trusted);
-      return new ConfigSet(configSetName(dcore), solrConfig, force -> 
createIndexSchema(dcore, solrConfig, force), properties, trusted);
+      return new ConfigSet(configSetName(dcore), solrConfig, force -> {
+        try {
+          return createIndexSchema(dcore, solrConfig, force);
+        } catch (IOException e) {
+          throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, 
e.getMessage(), e);
+        }
+      }, properties, trusted);
     } catch (Exception e) {
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
           "Could not load conf for core " + dcore.getName() +
@@ -288,7 +294,7 @@ public abstract class ConfigSetService {
    * @param solrConfig the core's SolrConfig
    * @return an IndexSchema
    */
-  protected IndexSchema createIndexSchema(CoreDescriptor cd, SolrConfig 
solrConfig, boolean forceFetch) {
+  protected IndexSchema createIndexSchema(CoreDescriptor cd, SolrConfig 
solrConfig, boolean forceFetch) throws IOException {
     // This is the schema name from the core descriptor.  Sometimes users 
specify a custom schema file.
     //   Important:  indexSchemaFactory.create wants this!
     String cdSchemaName = cd.getSchemaName();
@@ -320,7 +326,7 @@ public abstract class ConfigSetService {
    * Returns a modification version for the schema file.
    * Null may be returned if not known, and if so it defeats schema caching.
    */
-  protected abstract Long getCurrentSchemaModificationVersion(String 
configSet, SolrConfig solrConfig, String schemaFile);
+  protected abstract Long getCurrentSchemaModificationVersion(String 
configSet, SolrConfig solrConfig, String schemaFile) throws IOException;
 
   /**
    * Return the ConfigSet properties or null if none.
@@ -329,7 +335,7 @@ public abstract class ConfigSetService {
    * @param loader the core's resource loader
    * @return the ConfigSet properties
    */
-  protected NamedList<Object> loadConfigSetProperties(CoreDescriptor cd, 
SolrResourceLoader loader) {
+  protected NamedList<Object> loadConfigSetProperties(CoreDescriptor cd, 
SolrResourceLoader loader) throws IOException {
     return ConfigSetProperties.readFromResourceLoader(loader, 
cd.getConfigSetPropertiesName());
   }
 
@@ -337,7 +343,7 @@ public abstract class ConfigSetService {
    * Return the ConfigSet flags or null if none.
    */
   // TODO should fold into configSetProps -- SOLR-14059
-  protected NamedList<Object> loadConfigSetFlags(CoreDescriptor cd, 
SolrResourceLoader loader) {
+  protected NamedList<Object> loadConfigSetFlags(CoreDescriptor cd, 
SolrResourceLoader loader) throws IOException {
     return null;
   }
 
diff --git 
a/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java 
b/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java
index a4029a2..c6bdfbd 100644
--- a/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java
+++ b/solr/core/src/java/org/apache/solr/core/FileSystemConfigSetService.java
@@ -134,7 +134,7 @@ public class FileSystemConfigSetService extends 
ConfigSetService {
   }
 
   @Override
-  protected Long getCurrentSchemaModificationVersion(String configSet, 
SolrConfig solrConfig, String schemaFileName) {
+  protected Long getCurrentSchemaModificationVersion(String configSet, 
SolrConfig solrConfig, String schemaFileName) throws IOException {
     Path schemaFile = 
solrConfig.getResourceLoader().getConfigPath().resolve(schemaFileName);
     try {
       return Files.getLastModifiedTime(schemaFile).toMillis();
diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java 
b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
index 1dc977e..7c5e47c 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
@@ -525,7 +525,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
     }
 
     @Override
-    protected Long getCurrentSchemaModificationVersion(String configSet, 
SolrConfig solrConfig, String schemaFileName) {
+    protected Long getCurrentSchemaModificationVersion(String configSet, 
SolrConfig solrConfig, String schemaFileName) throws IOException {
       return null;
     }
   }

Reply via email to