Skip to content

Commit fe4fd00

Browse files
committed
Polishing contribution
Closes gh-33374
1 parent 1703b71 commit fe4fd00

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Diff for: spring-web/src/main/java/org/springframework/http/HttpHeaders.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -1048,9 +1048,8 @@ public long getDate() {
10481048
*/
10491049
public void setETag(@Nullable String etag) {
10501050
if (etag != null) {
1051-
Assert.isTrue(etag.startsWith("\"") || etag.startsWith("W/\""),
1052-
"Invalid ETag: does not start with W/\" or \"");
1053-
Assert.isTrue(etag.endsWith("\""), "Invalid ETag: does not end with \"");
1051+
Assert.isTrue(etag.startsWith("\"") || etag.startsWith("W/\""), "ETag does not start with W/\" or \"");
1052+
Assert.isTrue(etag.endsWith("\""), "ETag does not end with \"");
10541053
set(ETAG, etag);
10551054
}
10561055
else {

Diff for: spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ void ipv6Host() {
191191
}
192192

193193
@Test
194-
void illegalETag() {
194+
void illegalETagWithoutQuotes() {
195195
String eTag = "v2.6";
196196
assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(eTag));
197197
}
198198

199199
@Test
200-
void illegalETagWithoutQuoteAfterWSlash() {
200+
void illegalWeakETagWithoutLeadingQuote() {
201201
String etag = "W/v2.6\"";
202-
assertThatIllegalArgumentException().as("Invalid Weak ETag").isThrownBy(() -> headers.setETag(etag));
202+
assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(etag));
203203
}
204204

205205
@Test

0 commit comments

Comments
 (0)