From fe4fd004291a1f2704281eb839609cf9e2fb5bea Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Tue, 13 Aug 2024 16:59:13 +0300 Subject: [PATCH] Polishing contribution Closes gh-33374 --- .../main/java/org/springframework/http/HttpHeaders.java | 7 +++---- .../java/org/springframework/http/HttpHeadersTests.java | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index fe4ab934ae03..6afe9f5003ba 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1048,9 +1048,8 @@ public long getDate() { */ public void setETag(@Nullable String etag) { if (etag != null) { - Assert.isTrue(etag.startsWith("\"") || etag.startsWith("W/\""), - "Invalid ETag: does not start with W/\" or \""); - Assert.isTrue(etag.endsWith("\""), "Invalid ETag: does not end with \""); + Assert.isTrue(etag.startsWith("\"") || etag.startsWith("W/\""), "ETag does not start with W/\" or \""); + Assert.isTrue(etag.endsWith("\""), "ETag does not end with \""); set(ETAG, etag); } else { diff --git a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java index 0b53e092cc4d..80d62a344acd 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java @@ -191,15 +191,15 @@ void ipv6Host() { } @Test - void illegalETag() { + void illegalETagWithoutQuotes() { String eTag = "v2.6"; assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(eTag)); } @Test - void illegalETagWithoutQuoteAfterWSlash() { + void illegalWeakETagWithoutLeadingQuote() { String etag = "W/v2.6\""; - assertThatIllegalArgumentException().as("Invalid Weak ETag").isThrownBy(() -> headers.setETag(etag)); + assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(etag)); } @Test