Apache Lucene open-source search software
SOLR-9522: Improve error handling in ZKPropertiesWriter
Varun Thacker5d6b7fffc3e0
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex d8df854d85b..0d8bbcc864e 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -132,6 +132,8 @@ Bug Fixes* SOLR-9507: CoreContainer threads now correctly set their MDC logging values(Alan Woodward)+* SOLR-9522: Improve error handling in ZKPropertiesWriter (Varun Thacker)+Optimizations----------------------diff --git a/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/ZKPropertiesWriter.java b/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/ZKPropertiesWriter.javaindex 0bde409d23c..2d548726577 100644--- a/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/ZKPropertiesWriter.java+++ b/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/ZKPropertiesWriter.java@@ -44,14 +44,12 @@ public class ZKPropertiesWriter extends SimplePropertiesWriter {@Overridepublic void init(DataImporter dataImporter, Map<String, String> params) {super.init(dataImporter, params);- zkClient = dataImporter.getCore().getCoreDescriptor().getCoreContainer()- .getZkController().getZkClient();+ zkClient = dataImporter.getCore().getCoreDescriptor().getCoreContainer().getZkController().getZkClient();}@Overrideprotected void findDirectory(DataImporter dataImporter, Map<String, String> params) {- String collection = dataImporter.getCore().getCoreDescriptor()- .getCloudDescriptor().getCollectionName();+ String collection = dataImporter.getCore().getCoreDescriptor().getCloudDescriptor().getCollectionName();path = "/configs/" + collection + "/" + filename;}@@ -74,13 +72,9 @@ public class ZKPropertiesWriter extends SimplePropertiesWriter {} catch (NodeExistsException e) {}}zkClient.setData(path, bytes, false);- } catch (InterruptedException e) {- Thread.currentThread().interrupt();- log.warn(- "Could not persist properties to " + path + " :" + e.getClass(), e);} catch (Exception e) {- log.warn(- "Could not persist properties to " + path + " :" + e.getClass(), e);+ SolrZkClient.checkInterrupted(e);+ log.warn("Could not persist properties to " + path + " :" + e.getClass(), e);}}@@ -88,13 +82,13 @@ public class ZKPropertiesWriter extends SimplePropertiesWriter {public Map<String, Object> readIndexerProperties() {Properties props = new Properties();try {- byte[] data = zkClient.getData(path, null, null, false);+ byte[] data = zkClient.getData(path, null, null, true);if (data != null) {props.load(new StringReader(new String(data, StandardCharsets.UTF_8)));}} catch (Exception e) {- log.warn(- "Could not read DIH properties from " + path + " :" + e.getClass(), e);+ SolrZkClient.checkInterrupted(e);+ log.warn("Could not read DIH properties from " + path + " :" + e.getClass(), e);}return propertiesToMap(props);}