Skip to content

Commit

Permalink
Merge pull request #1130 from HubSpot/dont-limit-when-no-interpreter-…
Browse files Browse the repository at this point in the history
…exists

When there's no current JinjavaInterpreter, don't limit the maximum number of deferred tokens
  • Loading branch information
jasmith-hs authored Nov 13, 2023
2 parents 45d9375 + 51cb2f3 commit c34b97d
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 c34b97d

Please sign in to comment.