Skip to content

Commit 3eef39e

Browse files
committed
Polish contribution
See gh-35603
1 parent 87a7507 commit 3eef39e

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,13 @@ protected boolean isIncludePayload() {
188188
}
189189

190190
/**
191-
* Configure a predicate for selecting which query params should be logged if
192-
* {@link #setIncludeQueryString(boolean)} is set to {@code true}.
193-
* <p>By default this is not set in which case all query params are logged
194-
*
195-
* <p>If there are multiple values for the same query param,
196-
* the predicate will be applied once per query param name.
197-
* As a result, the use of this predicate may result in a different query string
198-
* than the one returned by {@link HttpServletRequest#getQueryString()}.
191+
* Configure a predicate for selecting which query parameters should be logged
192+
* if {@link #setIncludeQueryString(boolean)} is set to {@code true}.
193+
* <p>By default this is not set, in which case all query parameters are logged.
194+
* <p>The predicate will be applied once per query parameter name. Thus, if
195+
* there are multiple values for the same query parameter name, the logged query
196+
* string will contain fewer {@code name=value} mappings than the one returned by
197+
* {@link HttpServletRequest#getQueryString()}.
199198
* @param queryParamPredicate the predicate to use
200199
* @since 7.0
201200
*/
@@ -214,7 +213,7 @@ public void setQueryParamPredicate(@Nullable Predicate<String> queryParamPredica
214213
/**
215214
* Configure a predicate for selecting which headers should be logged if
216215
* {@link #setIncludeHeaders(boolean)} is set to {@code true}.
217-
* <p>By default this is not set in which case all headers are logged.
216+
* <p>By default this is not set, in which case all headers are logged.
218217
* @param headerPredicate the predicate to use
219218
* @since 5.2
220219
*/
@@ -364,7 +363,6 @@ protected String createMessage(HttpServletRequest request, String prefix, String
364363
for (String name : queryParams.keySet()) {
365364
if (!getQueryParamPredicate().test(name)) {
366365
updatedQueryParams.set(name, "masked");
367-
break;
368366
}
369367
}
370368

spring-web/src/test/java/org/springframework/web/filter/RequestLoggingFilterTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ void uri() throws Exception {
108108

109109
@Test
110110
void queryStringIncluded() throws Exception {
111-
request.setQueryString("booking=42&code=73&category=hotel&code=37&category=resort");
111+
request.setQueryString("booking=42&code=73&category=hotel&code=37&category=resort&ignore=enigma&code=99");
112112
filter.setIncludeQueryString(true);
113113
filter.setQueryParamPredicate(name -> !name.equals("code") && !name.equals("ignore"));
114114

115115
applyFilter();
116116

117-
assertThat(filter.beforeRequestMessage).contains("/hotels?booking=42&code=masked&category=hotel&category=resort");
118-
assertThat(filter.afterRequestMessage).contains("/hotels?booking=42&code=masked&category=hotel&category=resort");
117+
assertThat(filter.beforeRequestMessage).contains("/hotels?booking=42&code=masked&category=hotel&category=resort&ignore=masked");
118+
assertThat(filter.afterRequestMessage).contains("/hotels?booking=42&code=masked&category=hotel&category=resort&ignore=masked");
119119
}
120120

121121
@Test

0 commit comments

Comments
 (0)