Skip to content

Commit 3b41071

Browse files
mdeinumsnicoll
authored andcommitted
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
1 parent cea6492 commit 3b41071

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheViewResolver.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
* Spring WebFlux {@link ViewResolver} for Mustache.
2828
*
2929
* @author Brian Clozel
30+
* @author Marten Deinum
3031
* @since 2.0.0
3132
*/
3233
public class MustacheViewResolver extends UrlBasedViewResolver {
@@ -75,4 +76,9 @@ protected AbstractUrlBasedView createView(String viewName) {
7576
return view;
7677
}
7778

79+
@Override
80+
protected AbstractUrlBasedView instantiateView() {
81+
return (getViewClass() == MustacheView.class) ? new MustacheView() : super.instantiateView();
82+
}
83+
7884
}

0 commit comments

Comments
 (0)