You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2021/06/12 15:22:35 UTC

[lucene-solr] branch branch_8x updated: SolrZkClient: remove dead code (#2510)

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

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


The following commit(s) were added to refs/heads/branch_8x by this push:
     new b8bf6b3  SolrZkClient: remove dead code (#2510)
b8bf6b3 is described below

commit b8bf6b3ad7fd79fc793aeaecfb25de8d288802f6
Author: David Smiley <ds...@apache.org>
AuthorDate: Sat Jun 12 11:22:12 2021 -0400

    SolrZkClient: remove dead code (#2510)
    
    It's impossible for the "prettyPrint" code to be reached.  This has been so for 9 years.
---
 .../org/apache/solr/common/cloud/SolrZkClient.java | 33 ----------------------
 1 file changed, 33 deletions(-)

diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
index 42ec0f2..8ad1eaf 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
@@ -16,18 +16,10 @@
  */
 package org.apache.solr.common.cloud;
 
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
 import java.io.Closeable;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
-import java.io.StringReader;
-import java.io.StringWriter;
 import java.lang.invoke.MethodHandles;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
@@ -621,11 +613,6 @@ public class SolrZkClient implements Closeable {
     if (data != null) {
       String dataString = new String(data, StandardCharsets.UTF_8);
       if ((!path.endsWith(".txt") && !path.endsWith(".xml")) || path.endsWith(ZkStateReader.CLUSTER_STATE)) {
-        if (path.endsWith(".xml")) {
-          // this is the cluster state in xml format - lets pretty print
-          dataString = prettyPrint(dataString);
-        }
-
         string.append(dent).append("DATA:\n").append(dent).append("    ").append(dataString.replaceAll("\n", "\n" + dent + "    ")).append(NEWL);
       } else {
         string.append(dent).append("DATA: ...supressed...").append(NEWL);
@@ -659,26 +646,6 @@ public class SolrZkClient implements Closeable {
     out.println(sb.toString());
   }
 
-  public static String prettyPrint(String input, int indent) {
-    try {
-      Source xmlInput = new StreamSource(new StringReader(input));
-      StringWriter stringWriter = new StringWriter();
-      StreamResult xmlOutput = new StreamResult(stringWriter);
-      TransformerFactory transformerFactory = TransformerFactory.newInstance();
-      transformerFactory.setAttribute("indent-number", indent);
-      Transformer transformer = transformerFactory.newTransformer();
-      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-      transformer.transform(xmlInput, xmlOutput);
-      return xmlOutput.getWriter().toString();
-    } catch (Exception e) {
-      throw new RuntimeException("Problem pretty printing XML", e);
-    }
-  }
-
-  private static String prettyPrint(String input) {
-    return prettyPrint(input, 2);
-  }
-
   public void close() {
     if (isClosed) return; // it's okay if we over close - same as solrcore
     isClosed = true;