Apache Solr open-source search software
SOLR-15716: Remove deprecated SolrException.ignorePatterns and related code
Chris Hostetter1be2efd34987
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 412ae2143bb..915a3bf8dac 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 executiondiff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.javaindex 55e1dc3eb2d..4705d5fee7d 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 retrydiff --git a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.javaindex 5d8a3186c99..217066b75e6 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.javaindex 9b4a66ec8f0..6219800d7d5 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.javaindex cbea155e3c2..4a8a83bcd64 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*/@Deprecatedpublic 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*/@Deprecatedpublic 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*/@Deprecatedpublic 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 loopspublic static Throwable getRootCause(Throwable t) {while (true) {