From 3b410719e6ee339d1a2164cb27e9d99b57578882 Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Tue, 9 Aug 2022 11:17:17 +0200 Subject: [PATCH] Remove use of reflection in MustacheViewResolver Prior to this commit the MustacheViewResolver used reflection to instantiate a MustacheView class, which fails when using AOT. Creating the view without reflection (analogous to the FreemarkerViewResolver) will fix this without the need for additional constructor hints. See gh-32030 --- .../web/reactive/result/view/MustacheViewResolver.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheViewResolver.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheViewResolver.java index 3e7e440b04..7e4991d2f6 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheViewResolver.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheViewResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 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. @@ -27,6 +27,7 @@ import org.springframework.web.reactive.result.view.ViewResolver; * Spring WebFlux {@link ViewResolver} for Mustache. * * @author Brian Clozel + * @author Marten Deinum * @since 2.0.0 */ public class MustacheViewResolver extends UrlBasedViewResolver { @@ -75,4 +76,9 @@ public class MustacheViewResolver extends UrlBasedViewResolver { return view; } + @Override + protected AbstractUrlBasedView instantiateView() { + return (getViewClass() == MustacheView.class) ? new MustacheView() : super.instantiateView(); + } + }