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

hossman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 1be2efd  SOLR-15716: Remove deprecated SolrException.ignorePatterns 
and related code
1be2efd is described below

commit 1be2efd349870263d5f384307f8db7c07b1ea2a0
Author: Chris Hostetter <[email protected]>
AuthorDate: Tue Oct 26 10:57:05 2021 -0700

    SOLR-15716: Remove deprecated SolrException.ignorePatterns and related code
---
 solr/CHANGES.txt                                   |   2 +
 .../src/java/org/apache/solr/core/SolrCore.java    |   4 +-
 .../apache/solr/handler/MoreLikeThisHandler.java   |   4 +-
 .../solr/handler/component/ShardResponse.java      |   3 +-
 .../java/org/apache/solr/common/SolrException.java | 108 ---------------------
 5 files changed, 7 insertions(+), 114 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 412ae21..915a3bf 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -378,6 +378,8 @@ Other Changes
 
 * SOLR-15455: Facilitate joint Solr/Lucene development via local dependency 
substitution (Dawid Weiss, Michael Gibney)
 
+* SOLR-15716: Remove deprecated SolrException.ignorePatterns and related code 
(hossman)
+
 Bug Fixes
 ---------------------
 * SOLR-14546: Fix for a relatively hard to hit issue in OverseerTaskProcessor 
that could lead to out of order execution
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java 
b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 55e1dc3..4705d5f 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -2287,7 +2287,7 @@ public final class SolrCore implements SolrInfoBean, 
Closeable {
             searcherLock.wait();
           } catch (InterruptedException e) {
             if (log.isInfoEnabled()) {
-              log.info(SolrException.toStr(e));
+              log.info("Interupted waiting for searcherLock", e);
             }
           }
         }
@@ -2318,7 +2318,7 @@ public final class SolrCore implements SolrInfoBean, 
Closeable {
             searcherLock.wait();
           } catch (InterruptedException e) {
             if (log.isInfoEnabled()) {
-              log.info(SolrException.toStr(e));
+              log.info("Interupted waiting for searcherLock", e);
             }
           }
           continue;  // go back to the top of the loop and retry
diff --git 
a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java 
b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
index 5d8a318..217066b 100644
--- a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
@@ -264,8 +264,8 @@ public class MoreLikeThisHandler extends RequestHandlerBase
             }
             rsp.add("debug", dbgInfo);
           } catch (Exception e) {
-            SolrException.log(log, "Exception during debug", e);
-            rsp.add("exception_during_debug", SolrException.toStr(e));
+            log.error("Exception during debug: {}", e, e);
+            rsp.add("exception_during_debug", e.getMessage());
           }
         }
       } catch (ExitableDirectoryReader.ExitingReaderException ex) {
diff --git 
a/solr/core/src/java/org/apache/solr/handler/component/ShardResponse.java 
b/solr/core/src/java/org/apache/solr/handler/component/ShardResponse.java
index 9b4a66e..6219800 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/ShardResponse.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/ShardResponse.java
@@ -16,7 +16,6 @@
  */
 package org.apache.solr.handler.component;
 import org.apache.solr.client.solrj.SolrResponse;
-import org.apache.solr.common.SolrException;
 
 public final class ShardResponse {
   private ShardRequest req;
@@ -32,7 +31,7 @@ public final class ShardResponse {
     return "ShardResponse:{shard="+shard+",shardAddress="+shardAddress
             +"\n\trequest=" + req
             +"\n\tresponse=" + rsp
-            + (exception==null ? "" : "\n\texception="+ 
SolrException.toStr(exception))
+            + (exception==null ? "" : "\n\texception="+ exception)
             +"\n}";
   }
 
diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrException.java 
b/solr/solrj/src/java/org/apache/solr/common/SolrException.java
index cbea155..4a8a83b 100644
--- a/solr/solrj/src/java/org/apache/solr/common/SolrException.java
+++ b/solr/solrj/src/java/org/apache/solr/common/SolrException.java
@@ -16,11 +16,7 @@
  */
 package org.apache.solr.common;
 
-import java.io.CharArrayWriter;
-import java.io.PrintWriter;
 import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
 import org.apache.solr.common.util.NamedList;
 import org.slf4j.Logger;
 import org.slf4j.MDC;
@@ -140,7 +136,6 @@ public class SolrException extends RuntimeException {
   /** 
    * This method was initially created to aid in testing situations that were 
known to cause ERRORs.  It should no longer be used by any new code.
    *
-   * @see #ignorePatterns 
    * @deprecated Use the Logger directly
    */
   @Deprecated
@@ -151,17 +146,11 @@ public class SolrException extends RuntimeException {
   /** 
    * This method was initially created to aid in testing situations that were 
known to cause ERRORs.  It should no longer be used by any new code.
    *
-   * @see #ignorePatterns 
    * @deprecated Use the Logger directly
    */
   @Deprecated
   public static void log(Logger log, Throwable e) {
     if (log.isErrorEnabled()) {
-      String ignore = doIgnoreToStr(null, e);
-      if (ignore != null) {
-        log.info(ignore);
-        return;
-      }
       log.error(e.toString(), e); // nowarn (we are inside of isErrorEnabled, 
toString as msg is ok)
     }
   }
@@ -169,17 +158,11 @@ public class SolrException extends RuntimeException {
   /** 
    * This method was initially created to aid in testing situations that were 
known to cause ERRORs.  It should no longer be used by any new code.
    *
-   * @see #ignorePatterns 
    * @deprecated Use the Logger directly
    */
   @Deprecated
   public static void log(Logger log, String msg, Throwable e) {
     if (log.isErrorEnabled()) {
-      String ignore = doIgnoreToStr(msg, e);
-      if (ignore != null) {
-        log.info(ignore);
-        return;
-      }
       log.error(msg, e);
     }
   }
@@ -187,106 +170,15 @@ public class SolrException extends RuntimeException {
   /** 
    * This method was initially created to aid in testing situations that were 
known to cause ERRORs.  It should no longer be used by any new code.
    *
-   * @see #ignorePatterns 
    * @deprecated Use the Logger directly
    */
   @Deprecated
   public static void log(Logger log, String msg) {
     if (log.isErrorEnabled()) {
-      String ignore = doIgnoreToStr(msg, null);
-      if (ignore != null) {
-        log.info(ignore);
-        return;
-      }
       log.error(msg);
     }
   }
 
-  /** 
-   * This method was initially created to aid in testing situations that were 
known to cause ERRORs.  It should no longer be used by any new code.
-   *
-   * @see #ignorePatterns 
-   * @deprecated use {@link Throwable#printStackTrace} directly
-   */
-  @Deprecated
-  public static String toStr(Throwable e) {
-    CharArrayWriter cw = new CharArrayWriter();
-    PrintWriter pw = new PrintWriter(cw);
-    e.printStackTrace(pw);
-    pw.flush();
-    return cw.toString();
-  }
-
-  /**
-   * For test code: If non-null, prevents calls to {@link #log} from logging 
any msg or exception (stack trace) that matches an included regular expressions.
-   *
-   * A {@link java.util.concurrent.CopyOnWriteArraySet is recommended}.
-   *
-   * @deprecated use <code>ErrorLogMuter</code> in Solr test-framework.
-   */
-  @Deprecated
-  public static Set<String> ignorePatterns;
-
-  /** 
-   * Returns null if this exception does not match any ignore patterns; or an 
INFO message string to log instead if it does.
-   *
-   * @param t the original exception (only used for assertion checking)
-   * @param stacktrace the stringified stack trace of the exception, used for 
the acutal regex checking
-   * @see #ignorePatterns
-   * @see #toStr
-   * @deprecated use <code>ErrorLogMuter</code> in Solr test-framework.
-   */
-  @Deprecated
-  public static String doIgnore(Throwable t, String stacktrace) { 
-    if (t != null && t instanceof AssertionError) return null;
-    
-    Set<String> ignorePatterns = SolrException.ignorePatterns; // guard 
against races, albeit unlikely
-    // legacy public API: caller is required to have already stringified 
exception...
-    return doIgnoreToStr(ignorePatterns, stacktrace, null);
-  }
-
-  /** 
-   * @see #doIgnoreToStr(Set, String, Throwable) 
-   * @deprecated Not needed once {@link #ignorePatterns} is removed
-   */
-  @Deprecated
-  private static String doIgnoreToStr(String msg, Throwable t) {
-    if (t != null && t instanceof AssertionError) return null;
-    
-    Set<String> ignorePatterns = SolrException.ignorePatterns; // guard 
against races, albeit unlikely
-    return doIgnoreToStr(ignorePatterns, msg, t);
-  }
-  
-  /** 
-   * Returns null if the stringToCheck + exceptionToCheck does not match any 
of the ignore patterns; 
-   * or an INFO message string to log instead if it does.
-   *
-   * @param ignorePats patterns to match against
-   * @param stringToCheck arbitrary string to check against each ignore pattern
-   * @param exceptionToCheck if non-null, will be stringified and concatenated 
with stringToCheck before testing patterns
-   * @see #ignorePatterns
-   * @see #toStr
-   * @deprecated Not needed once {@link #ignorePatterns} is removed
-   */
-  @Deprecated
-  private static String doIgnoreToStr(Set<String> ignorePats, String 
stringToCheck, Throwable exceptionToCheck) {
-    if (null == ignorePats) return null;
-    
-    // we have some patterns, so we can't avoid stringifying exception for 
checks.
-    if (null != exceptionToCheck) {
-      // legacy concat of msg + throwable...
-      stringToCheck = (null == stringToCheck ? "" : stringToCheck+':') + 
toStr(exceptionToCheck);
-    }
-    
-    for (String regex : ignorePats) {
-      Pattern pattern = Pattern.compile(regex); // TODO why do we compile 
late; why not up-front?
-      
-      if (pattern.matcher(stringToCheck).find()) return "Ignoring exception 
matching " + regex;
-    }
-
-    return null;
-  }
-
   // TODO: This doesn't handle cause loops
     public static Throwable getRootCause(Throwable t) {
     while (true) {

Reply via email to