From 141ccdefd0902a2ce6f66073e76782607b75a968 Mon Sep 17 00:00:00 2001 From: Varun Thacker Date: Mon, 22 Aug 2016 01:08:36 +0530 Subject: [PATCH] SOLR-9428: Improve logging to log root cause --- .../org/apache/solr/rest/ManagedResourceStorage.java | 9 +++++---- .../java/org/apache/solr/common/cloud/ZkStateReader.java | 6 ++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java b/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java index 230bf44a25e..9db2fd27de7 100644 --- a/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java +++ b/solr/core/src/java/org/apache/solr/rest/ManagedResourceStorage.java @@ -84,7 +84,7 @@ public abstract class ManagedResourceStorage { * whether the core is running in cloud mode as well as initArgs. */ public static StorageIO newStorageIO(String collection, SolrResourceLoader resourceLoader, NamedList initArgs) { - StorageIO storageIO = null; + StorageIO storageIO; SolrZkClient zkClient = null; String zkConfigName = null; @@ -94,9 +94,10 @@ public abstract class ManagedResourceStorage { zkConfigName = ((ZkSolrResourceLoader)resourceLoader).getZkController(). getZkStateReader().readConfigName(collection); } catch (Exception e) { - log.error("Failed to get config name for collection {} due to: {}", - collection, e.toString()); - } + log.error("Failed to get config name due to", e); + throw new SolrException(ErrorCode.SERVER_ERROR, + "Failed to load config name for collection:" + collection + " due to: ", e); + } if (zkConfigName == null) { throw new SolrException(ErrorCode.SERVER_ERROR, "Could not find config name for collection:" + collection); diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java index a3de324e0a7..b89da93e504 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java @@ -192,10 +192,8 @@ public class ZkStateReader implements Closeable { } else { throw new ZooKeeperException(ErrorCode.INVALID_STATE, "No config data found at path: " + path); } - } catch (KeeperException e) { - throw new SolrException(ErrorCode.SERVER_ERROR, "Error loading config name for collection " + collection, e); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); + } catch (KeeperException| InterruptedException e) { + SolrZkClient.checkInterrupted(e); throw new SolrException(ErrorCode.SERVER_ERROR, "Error loading config name for collection " + collection, e); }