From d1c880621f28b10e174d10c5009b365f34626464 Mon Sep 17 00:00:00 2001 From: Michael Yan Date: Wed, 28 Jun 2023 17:48:17 +0800 Subject: [PATCH] Grails Plugin GSP: Fixes NPE in GroovyPagesAutoConfiguration Use `CollectionUtils.mergePropertiesIntoMap()` to simplify --- .../plugins/web/GroovyPagesAutoConfiguration.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesAutoConfiguration.java b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesAutoConfiguration.java index 8f76c0dc36..b3e01de214 100644 --- a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesAutoConfiguration.java +++ b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesAutoConfiguration.java @@ -19,7 +19,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.config.PropertiesFactoryBean; @@ -36,6 +35,7 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.springframework.util.ClassUtils; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.servlet.ViewResolver; @@ -134,12 +134,8 @@ public CachingGrailsConventionGroovyPageLocator groovyPageLocator(ObjectProvider pfb.setIgnoreResourceNotFound(true); pfb.setLocation(defaultViews); try { - Map precompiledGspMap = pfb.getObject().entrySet().stream().collect( - Collectors.toMap( - e -> String.valueOf(e.getKey()), - e -> String.valueOf(e.getValue()), - (prev, next) -> next, HashMap::new - )); + Map precompiledGspMap = new HashMap<>(); + CollectionUtils.mergePropertiesIntoMap(pfb.getObject(), precompiledGspMap); groovyPageLocator.setPrecompiledGspMap(precompiledGspMap); } catch (IOException ignored) {