Skip to content

Commit bd5326d

Browse files
committed
Remove unnecessary usages of DeferredParsingException which don't do
anything
1 parent d2a43f1 commit bd5326d

4 files changed

Lines changed: 16 additions & 29 deletions

File tree

src/main/java/com/hubspot/jinjava/el/NoInvokeELResolver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.hubspot.jinjava.el;
22

3-
import com.hubspot.jinjava.el.ext.DeferredParsingException;
3+
import com.hubspot.jinjava.interpret.DeferredValueException;
44
import java.beans.FeatureDescriptor;
55
import java.util.Iterator;
66
import javax.el.ELContext;
@@ -49,7 +49,7 @@ public boolean isReadOnly(ELContext elContext, Object base, Object property) {
4949

5050
@Override
5151
public void setValue(ELContext elContext, Object base, Object property, Object value) {
52-
throw new DeferredParsingException("NoInvokeELResolver");
52+
throw new DeferredValueException("NoInvokeELResolver");
5353
}
5454

5555
@Override
@@ -60,6 +60,6 @@ public Object invoke(
6060
Class<?>[] paramTypes,
6161
Object[] params
6262
) {
63-
throw new DeferredParsingException("NoInvokeELResolver");
63+
throw new DeferredValueException("NoInvokeELResolver");
6464
}
6565
}

src/main/java/com/hubspot/jinjava/el/ext/DeferredParsingException.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ public class DeferredParsingException extends DeferredValueException {
88
private final Object sourceNode;
99
private final IdentifierPreservationStrategy identifierPreservationStrategy;
1010

11-
public DeferredParsingException(String message) {
12-
super(message);
13-
this.deferredEvalResult = message;
14-
this.sourceNode = null;
15-
this.identifierPreservationStrategy = IdentifierPreservationStrategy.RESOLVING;
16-
}
17-
1811
public DeferredParsingException(Object sourceNode, String deferredEvalResult) {
1912
super(
2013
String.format(

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.hubspot.jinjava.doc.annotations.JinjavaParam;
2222
import com.hubspot.jinjava.doc.annotations.JinjavaSnippet;
2323
import com.hubspot.jinjava.doc.annotations.JinjavaTextMateSnippet;
24-
import com.hubspot.jinjava.el.ext.DeferredParsingException;
2524
import com.hubspot.jinjava.interpret.DeferredValue;
2625
import com.hubspot.jinjava.interpret.DeferredValueException;
2726
import com.hubspot.jinjava.interpret.InterpretException;
@@ -143,15 +142,10 @@ public String interpretUnchecked(TagNode tagNode, JinjavaInterpreter interpreter
143142
List<String> loopVars = loopVarsAndExpression.getLeft();
144143
String loopExpression = loopVarsAndExpression.getRight();
145144

146-
Object collection;
147-
try {
148-
collection =
149-
interpreter.resolveELExpression(loopExpression, tagNode.getLineNumber());
150-
} catch (DeferredParsingException e) {
151-
throw new DeferredParsingException(
152-
String.format("%s in %s", String.join(", ", loopVars), e.getDeferredEvalResult())
153-
);
154-
}
145+
Object collection = interpreter.resolveELExpression(
146+
loopExpression,
147+
tagNode.getLineNumber()
148+
);
155149
return renderForCollection(tagNode, interpreter, loopVars, collection);
156150
}
157151

src/main/java/com/hubspot/jinjava/random/DeferredRandomNumberGenerator.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.hubspot.jinjava.random;
22

3-
import com.hubspot.jinjava.el.ext.DeferredParsingException;
3+
import com.hubspot.jinjava.interpret.DeferredValueException;
44
import java.util.Random;
55
import java.util.stream.DoubleStream;
66
import java.util.stream.IntStream;
@@ -15,42 +15,42 @@ public class DeferredRandomNumberGenerator extends Random {
1515

1616
@Override
1717
protected int next(int bits) {
18-
throw new DeferredParsingException(EXCEPTION_MESSAGE);
18+
throw new DeferredValueException(EXCEPTION_MESSAGE);
1919
}
2020

2121
@Override
2222
public int nextInt() {
23-
throw new DeferredParsingException(EXCEPTION_MESSAGE);
23+
throw new DeferredValueException(EXCEPTION_MESSAGE);
2424
}
2525

2626
@Override
2727
public int nextInt(int bound) {
28-
throw new DeferredParsingException(EXCEPTION_MESSAGE);
28+
throw new DeferredValueException(EXCEPTION_MESSAGE);
2929
}
3030

3131
@Override
3232
public long nextLong() {
33-
throw new DeferredParsingException(EXCEPTION_MESSAGE);
33+
throw new DeferredValueException(EXCEPTION_MESSAGE);
3434
}
3535

3636
@Override
3737
public boolean nextBoolean() {
38-
throw new DeferredParsingException(EXCEPTION_MESSAGE);
38+
throw new DeferredValueException(EXCEPTION_MESSAGE);
3939
}
4040

4141
@Override
4242
public float nextFloat() {
43-
throw new DeferredParsingException(EXCEPTION_MESSAGE);
43+
throw new DeferredValueException(EXCEPTION_MESSAGE);
4444
}
4545

4646
@Override
4747
public double nextDouble() {
48-
throw new DeferredParsingException(EXCEPTION_MESSAGE);
48+
throw new DeferredValueException(EXCEPTION_MESSAGE);
4949
}
5050

5151
@Override
5252
public synchronized double nextGaussian() {
53-
throw new DeferredParsingException(EXCEPTION_MESSAGE);
53+
throw new DeferredValueException(EXCEPTION_MESSAGE);
5454
}
5555

5656
@Override

0 commit comments

Comments
 (0)