Skip to content

Commit

Permalink
bump basepom to 59.9
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredstehler committed May 10, 2024
1 parent 18bd026 commit 6afa327
Show file tree
Hide file tree
Showing 32 changed files with 112 additions and 195 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.hubspot</groupId>
<artifactId>basepom</artifactId>
<version>59.7</version>
<version>59.9</version>
</parent>

<groupId>com.hubspot.jinjava</groupId>
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/hubspot/jinjava/el/ExpressionResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,8 @@ private void handleELException(String expression, ELException e) {
TemplateError.fromException(
new TemplateSyntaxException(
expression,
(
e.getCause() == null ||
StringUtils.endsWith(originatingException, e.getCause().getMessage())
)
(e.getCause() == null ||
StringUtils.endsWith(originatingException, e.getCause().getMessage()))
? e.getMessage()
: combinedMessage,
interpreter.getLineNumber(),
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/hubspot/jinjava/el/ext/ExtendedParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,9 @@ private boolean isPossibleExpTestOrFilter(String namespace)
throws ParseException, ScanException {
if (
FILTER_PREFIX.substring(0, FILTER_PREFIX.length() - 1).equals(namespace) ||
EXPTEST_PREFIX.substring(0, EXPTEST_PREFIX.length() - 1).equals(namespace) &&
lookahead(1).getSymbol() == DOT &&
lookahead(2).getSymbol() == IDENTIFIER
(EXPTEST_PREFIX.substring(0, EXPTEST_PREFIX.length() - 1).equals(namespace) &&
lookahead(1).getSymbol() == DOT &&
lookahead(2).getSymbol() == IDENTIFIER)
) {
Token property = lookahead(2);
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,8 @@ public Object invoke(
if (
method == null ||
DEFAULT_RESTRICTED_METHODS.contains(method.toString()) ||
(
interpreter != null &&
interpreter.getConfig().getRestrictedMethods().contains(method.toString())
)
(interpreter != null &&
interpreter.getConfig().getRestrictedMethods().contains(method.toString()))
) {
throw new MethodNotFoundException(
"Cannot find method '" + method + "' in " + base.getClass()
Expand Down Expand Up @@ -221,10 +219,8 @@ private String validatePropertyName(Object property) {

if (
DEFAULT_RESTRICTED_PROPERTIES.contains(propertyName) ||
(
interpreter != null &&
interpreter.getConfig().getRestrictedProperties().contains(propertyName)
)
(interpreter != null &&
interpreter.getConfig().getRestrictedProperties().contains(propertyName))
) {
return null;
}
Expand Down Expand Up @@ -253,10 +249,8 @@ protected boolean isRestrictedClass(Object o) {
}

return (
(
o.getClass().getPackage() != null &&
o.getClass().getPackage().getName().startsWith("java.lang.reflect")
) ||
(o.getClass().getPackage() != null &&
o.getClass().getPackage().getName().startsWith("java.lang.reflect")) ||
o instanceof Class ||
o instanceof ClassLoader ||
o instanceof Thread ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ protected Object invoke(
if (types.length > 0) {
// This is just the AstFunction.invoke, but surrounded with this try-with-resources
try (
TemporaryValueClosable<Boolean> c = (
(JinjavaInterpreter) context
.getELResolver()
.getValue(context, null, ExtendedParser.INTERPRETER)
).getContext()
.withPartialMacroEvaluation(false)
TemporaryValueClosable<Boolean> c =
((JinjavaInterpreter) context
.getELResolver()
.getValue(context, null, ExtendedParser.INTERPRETER)).getContext()
.withPartialMacroEvaluation(false)
) {
params = new Object[types.length];
int varargIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ private EagerAstParameters(List<AstNode> nodes, boolean convertedToEvalResultHol
@Override
public Object[] eval(Bindings bindings, ELContext context) {
try (
TemporaryValueClosable<Boolean> c = (
(JinjavaInterpreter) context
.getELResolver()
.getValue(context, null, ExtendedParser.INTERPRETER)
).getContext()
.withPartialMacroEvaluation(false)
TemporaryValueClosable<Boolean> c =
((JinjavaInterpreter) context
.getELResolver()
.getValue(context, null, ExtendedParser.INTERPRETER)).getContext()
.withPartialMacroEvaluation(false)
) {
try {
setEvalResult(super.eval(bindings, context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ default Object checkEvalResultSize(ELContext context) {
if (
evalResult instanceof Collection &&
((Collection<?>) evalResult).size() > 100 && // TODO make size configurable
(
(JinjavaInterpreter) context
((JinjavaInterpreter) context
.getELResolver()
.getValue(context, null, ExtendedParser.INTERPRETER)
).getContext()
.getValue(context, null, ExtendedParser.INTERPRETER)).getContext()
.isDeferLargeObjects()
) {
throw new DeferredValueException("Collection too big");
Expand Down Expand Up @@ -83,8 +81,8 @@ static String reconstructNode(
preserveIdentifier =
IdentifierPreservationStrategy.preserving(
preserveIdentifier.isPreserving() ||
astNode instanceof AstIdentifier &&
ExtendedParser.INTERPRETER.equals(((AstIdentifier) astNode).getName())
(astNode instanceof AstIdentifier &&
ExtendedParser.INTERPRETER.equals(((AstIdentifier) astNode).getName()))
);
if (
preserveIdentifier.isPreserving() &&
Expand All @@ -107,13 +105,9 @@ static String reconstructNode(
}
if (
!preserveIdentifier.isPreserving() ||
(
astNode.hasEvalResult() &&
(
EagerExpressionResolver.isPrimitive(evalResult) ||
evalResult instanceof PartiallyDeferredValue
)
)
(astNode.hasEvalResult() &&
(EagerExpressionResolver.isPrimitive(evalResult) ||
evalResult instanceof PartiallyDeferredValue))
) {
if (exceptionMatchesNode(exception, astNode)) {
return exception.getDeferredEvalResult();
Expand All @@ -131,11 +125,9 @@ static String reconstructNode(
if (astNode instanceof AstIdentifier) {
String name = ((AstIdentifier) astNode).getName();
if (
(
(JinjavaInterpreter) context
((JinjavaInterpreter) context
.getELResolver()
.getValue(context, null, ExtendedParser.INTERPRETER)
).getContext()
.getValue(context, null, ExtendedParser.INTERPRETER)).getContext()
.getMetaContextVariables()
.contains(name)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,8 @@ private void resolveBlockStubs(OutputList output) {
private boolean isExtendsTag(Node node) {
return (
node instanceof TagNode &&
(
((TagNode) node).getTag() instanceof ExtendsTag ||
isEagerExtendsTag((TagNode) node)
)
(((TagNode) node).getTag() instanceof ExtendsTag ||
isEagerExtendsTag((TagNode) node))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ public RenderedOutputNode interpretOutput(
if (interpreter.getConfig().isNestedInterpretationEnabled()) {
if (
!StringUtils.equals(result, master.getImage()) &&
(
StringUtils.contains(result, master.getSymbols().getExpressionStart()) ||
StringUtils.contains(result, master.getSymbols().getExpressionStartWithTag())
)
(StringUtils.contains(result, master.getSymbols().getExpressionStart()) ||
StringUtils.contains(result, master.getSymbols().getExpressionStartWithTag()))
) {
try {
result = interpreter.renderFlat(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,8 @@ public static String postProcessResult(
) {
if (
!StringUtils.equals(result, master.getImage()) &&
(
StringUtils.contains(result, master.getSymbols().getExpressionStart()) ||
StringUtils.contains(result, master.getSymbols().getExpressionStartWithTag())
)
(StringUtils.contains(result, master.getSymbols().getExpressionStart()) ||
StringUtils.contains(result, master.getSymbols().getExpressionStartWithTag()))
) {
if (interpreter.getConfig().isNestedInterpretationEnabled()) {
long errorSizeStart = getParsingErrorsCount(interpreter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public Object filter(Object var, JinjavaInterpreter interpreter, String... args)
prefix = sizes[i];

if (bytes < unit) {
return String.format("%.1f %s", (double) (base * bytes / unit), prefix);
return String.format("%.1f %s", (double) ((base * bytes) / unit), prefix);
}
}

return String.format("%.1f %s", (double) (base * bytes / unit), prefix);
return String.format("%.1f %s", (double) ((base * bytes) / unit), prefix);
}

private static final String[] BINARY_SIZES = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,8 @@ private Object getValue(
List<String> parts = PREFIX_SPLITTER.splitToList(fullAddress);
if (
parts.size() == 1 &&
(
parameter.equalsIgnoreCase(PUBLIC_STRING) ||
parameter.equalsIgnoreCase(PRIVATE_STRING)
)
(parameter.equalsIgnoreCase(PUBLIC_STRING) ||
parameter.equalsIgnoreCase(PRIVATE_STRING))
) {
parts = new ArrayList<>(parts);
parts.add("0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,9 @@ public Object doEvaluate(
);
if (
!eagerExecutionResult.getResult().isFullyResolved() &&
(
!interpreter.getContext().isPartialMacroEvaluation() ||
(!interpreter.getContext().isPartialMacroEvaluation() ||
!eagerExecutionResult.getSpeculativeBindings().isEmpty() ||
interpreter.getContext().isDeferredExecutionMode()
)
interpreter.getContext().isDeferredExecutionMode())
) {
PrefixToPreserveState prefixToPreserveState =
EagerReconstructionUtils.resetAndDeferSpeculativeBindings(
Expand Down Expand Up @@ -251,10 +249,8 @@ public String reconstructImage(String fullName) {
}

if (
(
interpreter.getContext().getMacroStack().contains(getName()) &&
!differentMacroWithSameNameExists(interpreter)
) ||
(interpreter.getContext().getMacroStack().contains(getName()) &&
!differentMacroWithSameNameExists(interpreter)) ||
(!isCaller() && AstMacroFunction.checkAndPushMacroStack(interpreter, fullName))
) {
return "";
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/hubspot/jinjava/lib/tag/ForTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,8 @@ public String renderForCollection(
}
if (
interpreter.getConfig().getMaxNumDeferredTokens() <
(
loop.getLength() *
interpreter.getContext().getDeferredTokens().size() /
loop.getIndex()
)
((loop.getLength() * interpreter.getContext().getDeferredTokens().size()) /
loop.getIndex())
) {
throw new DeferredValueException(TOO_LARGE_EXCEPTION_MESSAGE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,8 @@ private static void deferDuplicatePointers(Context context, String word) {
.stream()
.filter(entry ->
entry.getValue() == wordValue ||
(
entry.getValue() instanceof DeferredValue &&
((DeferredValue) entry.getValue()).getOriginalValue() == wordValue
)
(entry.getValue() instanceof DeferredValue &&
((DeferredValue) entry.getValue()).getOriginalValue() == wordValue)
)
.forEach(entry -> {
matchingEntries.add(entry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ protected EagerExecutionResult getEagerExecutionResult(
.build()
);
if (
!eagerExecutionResult.getResult().isFullyResolved() &&
!eagerExecutionResult.getSpeculativeBindings().isEmpty() ||
(!eagerExecutionResult.getResult().isFullyResolved() &&
!eagerExecutionResult.getSpeculativeBindings().isEmpty()) ||
interpreter.getContext().isDeferredExecutionMode()
) {
EagerReconstructionUtils.resetAndDeferSpeculativeBindings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ public String eagerInterpret(
}
if (
StringUtils.isNotBlank(tagNode.getEndName()) &&
(
!(getTag() instanceof FlexibleTag) ||
((FlexibleTag) getTag()).hasEndTag((TagToken) tagNode.getMaster())
)
(!(getTag() instanceof FlexibleTag) ||
((FlexibleTag) getTag()).hasEndTag((TagToken) tagNode.getMaster()))
) {
result.append(EagerReconstructionUtils.reconstructEnd(tagNode));
} // Possible set tag in front of this one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ private int findNextElseToken(TagNode tagNode, int startIdx) {
for (i = startIdx; i < tagNode.getChildren().size(); i++) {
Node childNode = tagNode.getChildren().get(i);
if (
(TagNode.class.isAssignableFrom(childNode.getClass())) &&
childNode.getName().equals(ElseIfTag.TAG_NAME) ||
((TagNode.class.isAssignableFrom(childNode.getClass())) &&
childNode.getName().equals(ElseIfTag.TAG_NAME)) ||
childNode.getName().equals(ElseTag.TAG_NAME)
) {
return i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ public String getEagerTagImage(TagToken tagToken, JinjavaInterpreter interpreter
// and all defined variables and macros should be deferred too.
if (
!child.getContext().getDeferredNodes().isEmpty() ||
(
interpreter.getContext().isDeferredExecutionMode() &&
!child.getContext().getGlobalMacros().isEmpty()
)
(interpreter.getContext().isDeferredExecutionMode() &&
!child.getContext().getGlobalMacros().isEmpty())
) {
ImportTag.handleDeferredNodesDuringImport(
node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@ public static String interpretExpression(
// Possible macro/set tag in front of this one.
return (
prefixToPreserveState.toString() +
(
includeExpressionResult
(includeExpressionResult
? EagerReconstructionUtils.wrapInRawIfNeeded(
eagerExecutionResult.getResult().toString(true),
interpreter
)
: ""
)
: "")
);
}
EagerReconstructionUtils.hydrateReconstructionFromContextBeforeDeferring(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ public String eagerInterpret(
}
if (
StringUtils.isNotBlank(tagNode.getEndName()) &&
(
!(getTag() instanceof FlexibleTag) ||
((FlexibleTag) getTag()).hasEndTag((TagToken) tagNode.getMaster())
)
(!(getTag() instanceof FlexibleTag) ||
((FlexibleTag) getTag()).hasEndTag((TagToken) tagNode.getMaster()))
) {
result.append(EagerReconstructionUtils.reconstructEnd(tagNode));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ public void integrateChild(JinjavaInterpreter child) {
.entrySet()
.stream()
.filter(entry ->
!(
entry.getKey().equals(Context.GLOBAL_MACROS_SCOPE_KEY) ||
entry.getKey().equals(Context.IMPORT_RESOURCE_ALIAS_KEY)
)
!(entry.getKey().equals(Context.GLOBAL_MACROS_SCOPE_KEY) ||
entry.getKey().equals(Context.IMPORT_RESOURCE_ALIAS_KEY))
)
.forEach(entry -> mapForCurrentContextAlias.put(entry.getKey(), entry.getValue()));
}
Expand Down Expand Up @@ -207,9 +205,7 @@ private static Map<String, Object> getMapForCurrentContextAlias(
return (Map<String, Object>) parentValueForChild;
} else if (parentValueForChild instanceof DeferredValue) {
if (((DeferredValue) parentValueForChild).getOriginalValue() instanceof Map) {
return (Map<String, Object>) (
(DeferredValue) parentValueForChild
).getOriginalValue();
return (Map<String, Object>) ((DeferredValue) parentValueForChild).getOriginalValue();
}
Map<String, Object> newMap = new PyMap(new HashMap<>());
child
Expand Down
Loading

0 comments on commit 6afa327

Please sign in to comment.