Skip to content

Commit

Permalink
When there's no current JinjavaInterpreter, don't limit the maximum n…
Browse files Browse the repository at this point in the history
…umber of deferred tokens
  • Loading branch information
jasmith-hs committed Nov 13, 2023
1 parent 45d9375 commit 51cb2f3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/java/com/hubspot/jinjava/interpret/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,18 @@ public void checkNumberOfDeferredTokens() {
secondToLastContext = secondToLastContext.parent;
}
}
int maxNumDeferredTokens = JinjavaInterpreter
int currentNumDeferredTokens = secondToLastContext.deferredTokens.size();
JinjavaInterpreter
.getCurrentMaybe()
.map(i -> i.getConfig().getMaxNumDeferredTokens())
.orElse(1000);
if (secondToLastContext.deferredTokens.size() >= maxNumDeferredTokens) {
throw new DeferredValueException(
"Too many Deferred Tokens, max is " + maxNumDeferredTokens
.filter(maxNumDeferredTokens -> currentNumDeferredTokens >= maxNumDeferredTokens)
.ifPresent(
maxNumDeferredTokens -> {
throw new DeferredValueException(
"Too many Deferred Tokens, max is " + maxNumDeferredTokens
);
}
);
}
}

@Beta
Expand Down

0 comments on commit 51cb2f3

Please sign in to comment.