From ffffa055f0a3b9b529567c28c1a5c8b33c5d719e Mon Sep 17 00:00:00 2001 From: dugenkui03 Date: Thu, 17 Mar 2022 23:25:56 +0800 Subject: [PATCH] Return UnmodifiableMap in MVC PathVariableMapMethodArgumentResolver See gh-28127 Closes gh-28352 --- .../annotation/PathVariableMapMethodArgumentResolver.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolver.java index eb5b4b0884..bbfd5a54d3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2022 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. @@ -17,7 +17,6 @@ package org.springframework.web.servlet.mvc.method.annotation; import java.util.Collections; -import java.util.LinkedHashMap; import java.util.Map; import org.springframework.core.MethodParameter; @@ -63,7 +62,7 @@ public class PathVariableMapMethodArgumentResolver implements HandlerMethodArgum HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST); if (!CollectionUtils.isEmpty(uriTemplateVars)) { - return new LinkedHashMap<>(uriTemplateVars); + return Collections.unmodifiableMap(uriTemplateVars); } else { return Collections.emptyMap();