Skip to content

Commit

Permalink
Grails Plugin GSP: Fixes NPE in GroovyPagesAutoConfiguration
Browse files Browse the repository at this point in the history
Use `CollectionUtils.mergePropertiesIntoMap()` to simplify
  • Loading branch information
rainboyan committed Jun 28, 2023
1 parent 4930cd0 commit d1c8806
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -134,12 +134,8 @@ public CachingGrailsConventionGroovyPageLocator groovyPageLocator(ObjectProvider
pfb.setIgnoreResourceNotFound(true);
pfb.setLocation(defaultViews);
try {
Map<String, String> precompiledGspMap = pfb.getObject().entrySet().stream().collect(
Collectors.toMap(
e -> String.valueOf(e.getKey()),
e -> String.valueOf(e.getValue()),
(prev, next) -> next, HashMap::new
));
Map<String, String> precompiledGspMap = new HashMap<>();
CollectionUtils.mergePropertiesIntoMap(pfb.getObject(), precompiledGspMap);
groovyPageLocator.setPrecompiledGspMap(precompiledGspMap);
}
catch (IOException ignored) {
Expand Down

0 comments on commit d1c8806

Please sign in to comment.