Skip to content

Commit 2f690f0

Browse files
committed
Merge pull request #193 from jochenberger/speed-up-evaluation-abort
Speed up the abort of an evaluation
2 parents 9d0a363 + c521615 commit 2f690f0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
package com.jayway.jsonpath.internal;
22

33
public class EvaluationAbortException extends RuntimeException {
4+
5+
private static final long serialVersionUID = 4419305302960432348L;
6+
7+
// this is just a marker exception to abort evaluation, we don't care about
8+
// the stack
9+
@Override
10+
public Throwable fillInStackTrace() {
11+
return this;
12+
}
413
}

json-path/src/main/java/com/jayway/jsonpath/internal/path/EvaluationContextImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
*/
3939
public class EvaluationContextImpl implements EvaluationContext {
4040

41+
private static final EvaluationAbortException ABORT_EVALUATION = new EvaluationAbortException();
42+
4143
private final Configuration configuration;
4244
private final Object valueResult;
4345
private final Object pathResult;
@@ -84,7 +86,7 @@ public void addResult(String path, PathRef operation, Object model) {
8486
for (EvaluationListener listener : configuration().getEvaluationListeners()) {
8587
EvaluationListener.EvaluationContinuation continuation = listener.resultFound(new FoundResultImpl(idx, path, model));
8688
if(EvaluationListener.EvaluationContinuation.ABORT == continuation){
87-
throw new EvaluationAbortException();
89+
throw ABORT_EVALUATION;
8890
}
8991
}
9092
}

0 commit comments

Comments
 (0)