From 2a853aea6754341a069191999a53d2065f49cf34 Mon Sep 17 00:00:00 2001 From: Christoph Dreis Date: Fri, 4 Nov 2022 13:00:02 +0100 Subject: [PATCH] Avoid String allocations in MediaType.checkParameters Closes gh-29428 --- .../src/main/java/org/springframework/http/MediaType.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index c30efd4c3f0e..d3e83775109b 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -531,10 +531,10 @@ public MediaType(MimeType mimeType) { protected void checkParameters(String parameter, String value) { super.checkParameters(parameter, value); if (PARAM_QUALITY_FACTOR.equals(parameter)) { - value = unquote(value); - double d = Double.parseDouble(value); + String unquotedValue = unquote(value); + double d = Double.parseDouble(unquotedValue); Assert.isTrue(d >= 0D && d <= 1D, - "Invalid quality value \"" + value + "\": should be between 0.0 and 1.0"); + () -> "Invalid quality value \"" + value + "\": should be between 0.0 and 1.0"); } }