diff --git a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java index 7e72fad230..38295f2895 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -350,27 +350,22 @@ public class FormHttpMessageConverter implements HttpMessageConverter result = new LinkedMultiValueMap<>(pairs.length); - for (String pair : pairs) { - int idx = pair.indexOf('='); - if (idx == -1) { - try { + try { + for (String pair : pairs) { + int idx = pair.indexOf('='); + if (idx == -1) { result.add(URLDecoder.decode(pair, charset), null); } - catch (IllegalArgumentException ex) { - throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage); - } - } - else { - try { + else { String name = URLDecoder.decode(pair.substring(0, idx), charset); String value = URLDecoder.decode(pair.substring(idx + 1), charset); result.add(name, value); } - catch (IllegalArgumentException ex) { - throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage); - } } } + catch (IllegalArgumentException ex) { + throw new HttpMessageNotReadableException("Could not decode HTTP form payload", ex, inputMessage); + } return result; }