From 6caef9bb3c9dad61bddc28494b513c146f8ddfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=9D=AC=EB=A7=9D?= <105429536+esperar@users.noreply.github.com> Date: Tue, 19 Sep 2023 08:00:33 +0900 Subject: [PATCH] Refine ServerRequest.queryParamOrNull implementation Closes gh-31264 --- .../function/server/ServerRequestExtensions.kt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt index 86e37675f18..e9f05cc73f2 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt @@ -173,15 +173,7 @@ fun ServerRequest.attributeOrNull(name: String): Any? = attributes()[name] */ fun ServerRequest.queryParamOrNull(name: String): String? { val queryParamValues = queryParams()[name] - return if (CollectionUtils.isEmpty(queryParamValues)) { - null - } else { - var value: String? = queryParamValues!![0] - if (value == null) { - value = "" - } - value - } + return if (queryParamValues.isNullOrEmpty()) null else queryParamValues[0] ?: "" } /**