Skip to content

Commit 88ba76f

Browse files
authored
Merge pull request #826 from HubSpot/class-cast-import-path
[Eager Execution] Get original value of deferred_import_resource_path if it's a deferred value
2 parents 7b2563f + 854f5b0 commit 88ba76f

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/main/java/com/hubspot/jinjava/lib/tag/MacroTag.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,16 @@ public String interpret(TagNode tagNode, JinjavaInterpreter interpreter) {
119119
argNamesWithDefaults
120120
);
121121
MacroFunction macro;
122-
String contextImportResourcePath = (String) interpreter
122+
Object contextImportResourcePath = interpreter
123123
.getContext()
124-
.get(Context.DEFERRED_IMPORT_RESOURCE_PATH_KEY, "");
124+
.get(Context.DEFERRED_IMPORT_RESOURCE_PATH_KEY);
125+
if (contextImportResourcePath instanceof DeferredValue) {
126+
contextImportResourcePath =
127+
((DeferredValue) contextImportResourcePath).getOriginalValue();
128+
}
125129
boolean scopeEntered = false;
126130
try {
127-
if (StringUtils.isNotEmpty(contextImportResourcePath)) {
131+
if (StringUtils.isNotEmpty((String) contextImportResourcePath)) {
128132
scopeEntered = true;
129133
interpreter.enterScope();
130134
interpreter

0 commit comments

Comments
 (0)