From 56eb13560801e94d0baa1ef3a41f57b41085bfb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Thu, 24 Apr 2025 10:37:30 +0200 Subject: [PATCH] Fix AbstractJackson2HttpMessageConverter nullness This commit makes AbstractJackson2HttpMessageConverter#getObjectMappersForType return value non nullable as an empty map is returned in case of no registrations. Closes gh-34811 --- .../converter/json/AbstractJackson2HttpMessageConverter.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java index 89320c8656c..85501ab3154 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.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. @@ -184,7 +184,6 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener * or empty if in case of no registrations for the given class. * @since 5.3.4 */ - @Nullable public Map getObjectMappersForType(Class clazz) { for (Map.Entry, Map> entry : getObjectMapperRegistrations().entrySet()) { if (entry.getKey().isAssignableFrom(clazz)) {