diff --git a/pom.xml b/pom.xml index 57723ed5d..7e98ccf89 100644 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,14 @@ com.hubspot basepom - 59.11 + 63.4 com.hubspot.jinjava jinjava 2.8.1-SNAPSHOT + + ${project.groupId}:${project.artifactId} Jinja templating engine implemented in Java @@ -339,6 +341,13 @@ https://github.com/HubSpot/jinjava + + + The Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + jaredstehler @@ -359,7 +368,7 @@ - basepom.oss-release + basepom.central-release true true diff --git a/src/main/java/com/hubspot/jinjava/el/ext/ExtendedScanner.java b/src/main/java/com/hubspot/jinjava/el/ext/ExtendedScanner.java index bf54da80f..1116c275b 100644 --- a/src/main/java/com/hubspot/jinjava/el/ext/ExtendedScanner.java +++ b/src/main/java/com/hubspot/jinjava/el/ext/ExtendedScanner.java @@ -1,6 +1,7 @@ package com.hubspot.jinjava.el.ext; import de.odysseus.el.tree.impl.Scanner; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -58,6 +59,10 @@ protected boolean isWhitespace(char c) { } } + @SuppressFBWarnings( + value = "HSM_HIDING_METHOD", + justification = "Purposefully overriding to use static method instance of this class." + ) protected static void addKeyToken(Token token) { try { ADD_KEY_TOKEN_METHOD.invoke(null, token); diff --git a/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java b/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java index e60c70fc9..3f698eaa4 100644 --- a/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java +++ b/src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java @@ -61,7 +61,6 @@ import com.hubspot.jinjava.util.RenderLimitUtils; import com.hubspot.jinjava.util.Variable; import com.hubspot.jinjava.util.WhitespaceUtils; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -541,10 +540,6 @@ private boolean isEagerExtendsTag(TagNode node) { ); } - @SuppressFBWarnings( - justification = "Iterables#getFirst DOES allow null for default value", - value = "NP_NONNULL_PARAM_VIOLATION" - ) private void resolveBlockStubs(OutputList output, Stack blockNames) { for (BlockPlaceholderOutputNode blockPlaceholder : output.getBlocks()) { if (!blockNames.contains(blockPlaceholder.getBlockName())) { diff --git a/src/main/java/com/hubspot/jinjava/lib/filter/AbstractFilter.java b/src/main/java/com/hubspot/jinjava/lib/filter/AbstractFilter.java index d53d2a97f..b39344c05 100644 --- a/src/main/java/com/hubspot/jinjava/lib/filter/AbstractFilter.java +++ b/src/main/java/com/hubspot/jinjava/lib/filter/AbstractFilter.java @@ -21,7 +21,6 @@ import com.hubspot.jinjava.doc.annotations.JinjavaParam; import com.hubspot.jinjava.interpret.InvalidInputException; import com.hubspot.jinjava.interpret.JinjavaInterpreter; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; @@ -69,10 +68,6 @@ public Object filter(Object var, JinjavaInterpreter interpreter, String... args) return filter(var, interpreter, args, Collections.emptyMap()); } - @SuppressFBWarnings( - value = "UC_USELESS_OBJECT", - justification = "FB bug prevents forEach() method call counting `namedArgs` as used (fixed in next release)" - ) public Object filter( Object var, JinjavaInterpreter interpreter, diff --git a/src/main/java/com/hubspot/jinjava/lib/fn/eager/EagerMacroFunction.java b/src/main/java/com/hubspot/jinjava/lib/fn/eager/EagerMacroFunction.java index 29a4fcf69..18a649794 100644 --- a/src/main/java/com/hubspot/jinjava/lib/fn/eager/EagerMacroFunction.java +++ b/src/main/java/com/hubspot/jinjava/lib/fn/eager/EagerMacroFunction.java @@ -28,6 +28,7 @@ import java.util.Map.Entry; import java.util.Optional; import java.util.StringJoiner; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.function.Supplier; @@ -38,7 +39,7 @@ public class EagerMacroFunction extends MacroFunction { private AtomicInteger callCount = new AtomicInteger(); - private boolean reconstructing = false; + private AtomicBoolean reconstructing = new AtomicBoolean(); public EagerMacroFunction( List content, @@ -70,7 +71,7 @@ public Object doEvaluate( List varArgs ) { JinjavaInterpreter interpreter = JinjavaInterpreter.getCurrent(); - if (reconstructing) { + if (reconstructing.get()) { try ( InterpreterScopeClosable c = interpreter.enterScope(); AutoCloseableImpl> importFile = getImportFileWithWrapper( @@ -282,7 +283,7 @@ public String reconstructImage(String fullName) { } try (InterpreterScopeClosable c = interpreter.enterScope()) { - reconstructing = true; + reconstructing.set(true); String evaluation = (String) evaluate( getArguments().stream().map(arg -> DeferredMacroValueImpl.instance()).toArray() ); @@ -300,7 +301,7 @@ public String reconstructImage(String fullName) { } result.append(super.reconstructImage()); } finally { - reconstructing = false; + reconstructing.set(false); interpreter .getContext() .put(Context.DEFERRED_IMPORT_RESOURCE_PATH_KEY, currentDeferredImportResource); diff --git a/src/main/java/com/hubspot/jinjava/mode/NonRevertingEagerExecutionMode.java b/src/main/java/com/hubspot/jinjava/mode/NonRevertingEagerExecutionMode.java index 536e2c0ff..00ccc7d53 100644 --- a/src/main/java/com/hubspot/jinjava/mode/NonRevertingEagerExecutionMode.java +++ b/src/main/java/com/hubspot/jinjava/mode/NonRevertingEagerExecutionMode.java @@ -1,11 +1,17 @@ package com.hubspot.jinjava.mode; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + public class NonRevertingEagerExecutionMode extends EagerExecutionMode { private static final ExecutionMode INSTANCE = new NonRevertingEagerExecutionMode(); protected NonRevertingEagerExecutionMode() {} + @SuppressFBWarnings( + value = "HSM_HIDING_METHOD", + justification = "Purposefully overriding to return static instance of this class." + ) public static ExecutionMode instance() { return INSTANCE; }