Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-15258: ConfigSetService operations ought to throw IOException (#221)

Nazerke Seidan6ea51f791d7b
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 604b9cc9afd..21a8b80165e 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 abab0f167ef..73e3f2077f5 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 a4029a20743..c6bdfbd64b4 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 1dc977e0b6f..7c5e47cc793 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;
}
}