Skip to content

Commit 46859d6

Browse files
committed
Polishing
Closes gh-34594
1 parent 573e74b commit 46859d6

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -350,27 +350,22 @@ public MultiValueMap<String, String> read(@Nullable Class<? extends MultiValueMa
350350

351351
String[] pairs = StringUtils.tokenizeToStringArray(body, "&");
352352
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(pairs.length);
353-
for (String pair : pairs) {
354-
int idx = pair.indexOf('=');
355-
if (idx == -1) {
356-
try {
353+
try {
354+
for (String pair : pairs) {
355+
int idx = pair.indexOf('=');
356+
if (idx == -1) {
357357
result.add(URLDecoder.decode(pair, charset), null);
358358
}
359-
catch (IllegalArgumentException ex) {
360-
throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage);
361-
}
362-
}
363-
else {
364-
try {
359+
else {
365360
String name = URLDecoder.decode(pair.substring(0, idx), charset);
366361
String value = URLDecoder.decode(pair.substring(idx + 1), charset);
367362
result.add(name, value);
368363
}
369-
catch (IllegalArgumentException ex) {
370-
throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage);
371-
}
372364
}
373365
}
366+
catch (IllegalArgumentException ex) {
367+
throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage);
368+
}
374369
return result;
375370
}
376371

0 commit comments

Comments
 (0)