From 21bf9c6e8045adce3301a7a92766f9c43a49ba71 Mon Sep 17 00:00:00 2001 From: Varun Thacker Date: Fri, 4 Mar 2016 18:08:53 +0530 Subject: [PATCH] SOLR-8779: Fix missing InterruptedException handling in ZkStateReader --- solr/CHANGES.txt | 2 ++ .../solr/common/cloud/ZkStateReader.java | 32 ++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index b8f4294f471..60d3f4d2003 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -265,6 +265,8 @@ Bug Fixes * SOLR-8728: ReplicaAssigner throws NPE when a partial list of nodes are only participating in replica placement. splitshard should preassign nodes using rules, if rules are present (noble, Shai Erera) +* SOLR-8779: Fix missing InterruptedException handling in ZkStateReader.java (Varun Thacker) + Optimizations ---------------------- * SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been 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 e515d6670d7..3dbc6d2876d 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 @@ -165,12 +165,10 @@ public class ZkStateReader implements Closeable { } else { throw new ZooKeeperException(ErrorCode.INVALID_STATE, "No config data found at path: " + path); } - } - catch (KeeperException e) { + } catch (KeeperException e) { throw new SolrException(ErrorCode.SERVER_ERROR, "Error loading config name for collection " + collection, e); - } - catch (InterruptedException e) { - Thread.interrupted(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); throw new SolrException(ErrorCode.SERVER_ERROR, "Error loading config name for collection " + collection, e); } @@ -691,14 +689,17 @@ public class ZkStateReader implements Closeable { this.aliases = ClusterState.load(data); } - public Map getClusterProps(){ + public Map getClusterProps() { try { if (getZkClient().exists(ZkStateReader.CLUSTER_PROPS, true)) { return (Map) Utils.fromJSON(getZkClient().getData(ZkStateReader.CLUSTER_PROPS, null, new Stat(), true)) ; } else { return new LinkedHashMap(); } - } catch (Exception e) { + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new SolrException(ErrorCode.SERVER_ERROR, "Thread interrupted. Error reading cluster properties", e); + } catch (KeeperException e) { throw new SolrException(ErrorCode.SERVER_ERROR, "Error reading cluster properties", e); } } @@ -741,9 +742,13 @@ public class ZkStateReader implements Closeable { LOG.warn("Race condition while trying to set a new cluster prop on current version [{}]", s.getVersion()); //race condition continue; - } catch (Exception ex) { - LOG.error("Error updating path [{}]", CLUSTER_PROPS, ex); - throw new SolrException(ErrorCode.SERVER_ERROR, "Error updating cluster property " + propertyName, ex); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + LOG.error("Thread Interrupted. Error updating path [{}]", CLUSTER_PROPS, e); + throw new SolrException(ErrorCode.SERVER_ERROR, "Thread Interrupted. Error updating cluster property " + propertyName, e); + } catch (KeeperException e) { + LOG.error("Error updating path [{}]", CLUSTER_PROPS, e); + throw new SolrException(ErrorCode.SERVER_ERROR, "Error updating cluster property " + propertyName, e); } break; } @@ -766,8 +771,11 @@ public class ZkStateReader implements Closeable { new ConfigData((Map) Utils.fromJSON(data), stat.getVersion()) : null; } - } catch (KeeperException | InterruptedException e) { - throw new SolrException(ErrorCode.SERVER_ERROR,"Error reading security properties",e) ; + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new SolrException(ErrorCode.SERVER_ERROR,"Error reading security properties", e) ; + } catch (KeeperException e) { + throw new SolrException(ErrorCode.SERVER_ERROR,"Error reading security properties", e) ; } return null; }