2626import java .util .Map .Entry ;
2727import java .util .Optional ;
2828import java .util .StringJoiner ;
29+ import java .util .concurrent .atomic .AtomicBoolean ;
2930import java .util .concurrent .atomic .AtomicInteger ;
3031import java .util .function .Function ;
3132import java .util .function .Supplier ;
3637public class EagerMacroFunction extends MacroFunction {
3738
3839 private AtomicInteger callCount = new AtomicInteger ();
39- private boolean reconstructing = false ;
40+ private AtomicBoolean reconstructing = new AtomicBoolean () ;
4041
4142 public EagerMacroFunction (
4243 List <Node > content ,
@@ -68,7 +69,7 @@ public Object doEvaluate(
6869 List <Object > varArgs
6970 ) {
7071 JinjavaInterpreter interpreter = JinjavaInterpreter .getCurrent ();
71- if (reconstructing ) {
72+ if (reconstructing . get () ) {
7273 Optional <String > importFile = getImportFile (interpreter );
7374 try (InterpreterScopeClosable c = interpreter .enterScope ()) {
7475 EagerExecutionResult result = eagerEvaluateInDeferredExecutionMode (
@@ -266,7 +267,7 @@ public String reconstructImage(String fullName) {
266267 return "" ;
267268 } else {
268269 try (InterpreterScopeClosable c = interpreter .enterScope ()) {
269- reconstructing = true ;
270+ reconstructing . set ( true ) ;
270271 String evaluation = (String ) evaluate (
271272 getArguments ().stream ().map (arg -> DeferredMacroValueImpl .instance ()).toArray ()
272273 );
@@ -284,7 +285,7 @@ public String reconstructImage(String fullName) {
284285 }
285286 result .append (super .reconstructImage ());
286287 } finally {
287- reconstructing = false ;
288+ reconstructing . set ( false ) ;
288289 interpreter
289290 .getContext ()
290291 .put (Context .DEFERRED_IMPORT_RESOURCE_PATH_KEY , currentDeferredImportResource );
0 commit comments