Apache Solr open-source search software
SOLR-18108: remove deprecated method from AuditEvent (#4143)
Eric Pughe0fe9619839f
diff --git a/changelog/unreleased/SOLR-18108.yml b/changelog/unreleased/SOLR-18108.ymlnew file mode 100644index 00000000000..e80fa568e02--- /dev/null+++ b/changelog/unreleased/SOLR-18108.yml@@ -0,0 +1,8 @@+# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc+title: Remove the deprecated getRequestUrl method from AuditEvent+type: removed # added, changed, fixed, deprecated, removed, dependency_update, security, other+authors:+ - name: Eric Pugh+links:+ - name: SOLR-18108+ url: https://issues.apache.org/jira/browse/SOLR-18108diff --git a/solr/core/src/java/org/apache/solr/security/AuditEvent.java b/solr/core/src/java/org/apache/solr/security/AuditEvent.javaindex dc7de8b572b..e3367e8d8ea 100644--- a/solr/core/src/java/org/apache/solr/security/AuditEvent.java+++ b/solr/core/src/java/org/apache/solr/security/AuditEvent.java@@ -19,7 +19,6 @@ package org.apache.solr.security;import static org.apache.solr.security.AuditEvent.EventType.ANONYMOUS;import static org.apache.solr.security.AuditEvent.EventType.ERROR;-import com.fasterxml.jackson.annotation.JsonIgnore;import jakarta.servlet.http.HttpServletRequest;import java.lang.invoke.MethodHandles;import java.security.Principal;@@ -100,7 +99,7 @@ public class AuditEvent {/*** Empty event, must be filled by user using setters. Message and Loglevel will be initialized- * from EventType but can be overridden with setters afterwards.+ * from EventType but can be overridden with setters afterward.** @param eventType a predefined or custom EventType*/@@ -121,7 +120,7 @@ public class AuditEvent {/*** Event based on an HttpServletRequest, typically used during authentication. Solr will fill in- * details such as ip, http method etc from the request, and username if Principal exists on the+ * details such as ip, http method etc. from the request, and username if Principal exists on the* request.** @param eventType a predefined or custom EventType@@ -163,7 +162,7 @@ public class AuditEvent {/*** Event based on request and AuthorizationContext. Solr will fill in details such as collections,- * ip, http method etc from the context.+ * ip, http method etc. from the context.** @param eventType a predefined or custom EventType* @param httpRequest the request to initialize from@@ -192,7 +191,7 @@ public class AuditEvent {/*** Event to log completed requests. Takes time and status. Solr will fill in details such as- * collections, ip, http method etc from the HTTP request and context.+ * collections, ip, http method etc. from the HTTP request and context.** @param eventType a predefined or custom EventType* @param httpRequest the request to initialize from@@ -248,7 +247,7 @@ public class AuditEvent {}}- /** The human readable message about this event */+ /** The human-readable message about this event */public String getMessage() {return message;}@@ -267,7 +266,7 @@ public class AuditEvent {return date;}- /** Username of logged in user, or null if no authenticated user */+ /** Username of logged-in user, or null if no authenticated user */public String getUsername() {return username;}@@ -349,7 +348,7 @@ public class AuditEvent {* Gets first value of a certain Solr request parameter** @param key name of request parameter to retrieve- * @return String value of the first value, regardless of number of valies+ * @return String value of the first value, regardless of number of values*/public String getSolrParamAsString(String key) {List<String> v = getSolrParams().get(key);@@ -393,19 +392,6 @@ public class AuditEvent {return exception;}- /**- * Get baseUrl as StringBuffer for back compat with previous version- *- * @deprecated Please use {@link #getBaseUrl()} instead- * @return StringBuffer of the base url without query part- */- @Deprecated- @JsonIgnore- @SuppressWarnings("JdkObsolete")- public StringBuffer getRequestUrl() {- return new StringBuffer(baseUrl);- }-/*** Full URL of the original request. This is {@link #baseUrl} + "?" + {@link #httpQueryString}.* Returns null if not set@@ -580,11 +566,11 @@ public class AuditEvent {Arrays.asList(".*/select.*", ".*/query.*");private static final List<Pattern> ADMIN_PATH_PATTERNS =- ADMIN_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());+ ADMIN_PATH_REGEXES.stream().map(Pattern::compile).toList();private static final List<Pattern> STREAMING_PATH_PATTERNS =- STREAMING_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());+ STREAMING_PATH_REGEXES.stream().map(Pattern::compile).toList();private static final List<Pattern> INDEXING_PATH_PATTERNS =- INDEXING_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());+ INDEXING_PATH_REGEXES.stream().map(Pattern::compile).toList();private static final List<Pattern> SEARCH_PATH_PATTERNS =- SEARCH_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());+ SEARCH_PATH_REGEXES.stream().map(Pattern::compile).toList();}diff --git a/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java b/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.javaindex 32dec177433..3e2b3165cca 100644--- a/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java+++ b/solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java@@ -229,8 +229,6 @@ public class AuditLoggerPluginTest extends SolrTestCaseJ4 {@Testpublic void getBaseUrl() {assertEquals("http://myserver/mypath", EVENT_WITH_URL.getBaseUrl());- // Deprecated- assertEquals("http://myserver/mypath", EVENT_WITH_URL.getRequestUrl().toString());}@Test