From 22693c17f3cb3f08f49d159c5b6a57780f81ce76 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 3 Nov 2020 14:15:47 +0000 Subject: [PATCH] Align MustacheViewResolver with other similar resolvers The `FreeMarkerViewResolver` (and other template-based resolvers) in Spring Framework avoid using reflection if they know how to instantiate the view class. This change aligns with them. See gh-24011 --- .../boot/web/servlet/view/MustacheViewResolver.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/MustacheViewResolver.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/MustacheViewResolver.java index 955d8d4cf7..cf5bf6ae3c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/MustacheViewResolver.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/MustacheViewResolver.java @@ -75,4 +75,9 @@ public class MustacheViewResolver extends AbstractTemplateViewResolver { return view; } + @Override + protected AbstractUrlBasedView instantiateView() { + return (getViewClass() == MustacheView.class ? new MustacheView() : super.instantiateView()); + } + }