Skip to content

Commit e0fe961

Browse files
authored
SOLR-18108: remove deprecated method from AuditEvent (#4143)
1 parent f80dc74 commit e0fe961

File tree

3 files changed

+19
-27
lines changed

3 files changed

+19
-27
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
2+
title: Remove the deprecated getRequestUrl method from AuditEvent
3+
type: removed # added, changed, fixed, deprecated, removed, dependency_update, security, other
4+
authors:
5+
- name: Eric Pugh
6+
links:
7+
- name: SOLR-18108
8+
url: https://issues.apache.org/jira/browse/SOLR-18108

solr/core/src/java/org/apache/solr/security/AuditEvent.java

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import static org.apache.solr.security.AuditEvent.EventType.ANONYMOUS;
2020
import static org.apache.solr.security.AuditEvent.EventType.ERROR;
2121

22-
import com.fasterxml.jackson.annotation.JsonIgnore;
2322
import jakarta.servlet.http.HttpServletRequest;
2423
import java.lang.invoke.MethodHandles;
2524
import java.security.Principal;
@@ -100,7 +99,7 @@ public enum EventType {
10099

101100
/**
102101
* Empty event, must be filled by user using setters. Message and Loglevel will be initialized
103-
* from EventType but can be overridden with setters afterwards.
102+
* from EventType but can be overridden with setters afterward.
104103
*
105104
* @param eventType a predefined or custom EventType
106105
*/
@@ -121,7 +120,7 @@ protected AuditEvent() {}
121120

122121
/**
123122
* Event based on an HttpServletRequest, typically used during authentication. Solr will fill in
124-
* details such as ip, http method etc from the request, and username if Principal exists on the
123+
* details such as ip, http method etc. from the request, and username if Principal exists on the
125124
* request.
126125
*
127126
* @param eventType a predefined or custom EventType
@@ -163,7 +162,7 @@ public AuditEvent(EventType eventType, Throwable exception, HttpServletRequest h
163162

164163
/**
165164
* Event based on request and AuthorizationContext. Solr will fill in details such as collections,
166-
* ip, http method etc from the context.
165+
* ip, http method etc. from the context.
167166
*
168167
* @param eventType a predefined or custom EventType
169168
* @param httpRequest the request to initialize from
@@ -192,7 +191,7 @@ public AuditEvent(
192191

193192
/**
194193
* Event to log completed requests. Takes time and status. Solr will fill in details such as
195-
* collections, ip, http method etc from the HTTP request and context.
194+
* collections, ip, http method etc. from the HTTP request and context.
196195
*
197196
* @param eventType a predefined or custom EventType
198197
* @param httpRequest the request to initialize from
@@ -248,7 +247,7 @@ static RequestType convertType(AuthorizationContext.RequestType ctxReqType) {
248247
}
249248
}
250249

251-
/** The human readable message about this event */
250+
/** The human-readable message about this event */
252251
public String getMessage() {
253252
return message;
254253
}
@@ -267,7 +266,7 @@ public Date getDate() {
267266
return date;
268267
}
269268

270-
/** Username of logged in user, or null if no authenticated user */
269+
/** Username of logged-in user, or null if no authenticated user */
271270
public String getUsername() {
272271
return username;
273272
}
@@ -349,7 +348,7 @@ public Map<String, List<String>> getSolrParams() {
349348
* Gets first value of a certain Solr request parameter
350349
*
351350
* @param key name of request parameter to retrieve
352-
* @return String value of the first value, regardless of number of valies
351+
* @return String value of the first value, regardless of number of values
353352
*/
354353
public String getSolrParamAsString(String key) {
355354
List<String> v = getSolrParams().get(key);
@@ -393,19 +392,6 @@ public Throwable getException() {
393392
return exception;
394393
}
395394

396-
/**
397-
* Get baseUrl as StringBuffer for back compat with previous version
398-
*
399-
* @deprecated Please use {@link #getBaseUrl()} instead
400-
* @return StringBuffer of the base url without query part
401-
*/
402-
@Deprecated
403-
@JsonIgnore
404-
@SuppressWarnings("JdkObsolete")
405-
public StringBuffer getRequestUrl() {
406-
return new StringBuffer(baseUrl);
407-
}
408-
409395
/**
410396
* Full URL of the original request. This is {@link #baseUrl} + "?" + {@link #httpQueryString}.
411397
* Returns null if not set
@@ -580,11 +566,11 @@ protected String normalizeResourcePath(String resourcePath) {
580566
Arrays.asList(".*/select.*", ".*/query.*");
581567

582568
private static final List<Pattern> ADMIN_PATH_PATTERNS =
583-
ADMIN_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());
569+
ADMIN_PATH_REGEXES.stream().map(Pattern::compile).toList();
584570
private static final List<Pattern> STREAMING_PATH_PATTERNS =
585-
STREAMING_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());
571+
STREAMING_PATH_REGEXES.stream().map(Pattern::compile).toList();
586572
private static final List<Pattern> INDEXING_PATH_PATTERNS =
587-
INDEXING_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());
573+
INDEXING_PATH_REGEXES.stream().map(Pattern::compile).toList();
588574
private static final List<Pattern> SEARCH_PATH_PATTERNS =
589-
SEARCH_PATH_REGEXES.stream().map(Pattern::compile).collect(Collectors.toList());
575+
SEARCH_PATH_REGEXES.stream().map(Pattern::compile).toList();
590576
}

solr/core/src/test/org/apache/solr/security/AuditLoggerPluginTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ public void jsonEventFormatter() {
229229
@Test
230230
public void getBaseUrl() {
231231
assertEquals("http://myserver/mypath", EVENT_WITH_URL.getBaseUrl());
232-
// Deprecated
233-
assertEquals("http://myserver/mypath", EVENT_WITH_URL.getRequestUrl().toString());
234232
}
235233

236234
@Test

0 commit comments

Comments
 (0)