Browse Source

Merge pull request #193 from jochenberger/speed-up-evaluation-abort

Speed up the abort of an evaluation
pull/195/head
kallestenflo 9 years ago
parent
commit
2f690f0857
  1. 9
      json-path/src/main/java/com/jayway/jsonpath/internal/EvaluationAbortException.java
  2. 4
      json-path/src/main/java/com/jayway/jsonpath/internal/path/EvaluationContextImpl.java

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

@ -1,4 +1,13 @@
package com.jayway.jsonpath.internal;
public class EvaluationAbortException extends RuntimeException {
private static final long serialVersionUID = 4419305302960432348L;
// this is just a marker exception to abort evaluation, we don't care about
// the stack
@Override
public Throwable fillInStackTrace() {
return this;
}
}

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

@ -38,6 +38,8 @@ import static com.jayway.jsonpath.internal.Utils.notNull;
*/
public class EvaluationContextImpl implements EvaluationContext {
private static final EvaluationAbortException ABORT_EVALUATION = new EvaluationAbortException();
private final Configuration configuration;
private final Object valueResult;
private final Object pathResult;
@ -84,7 +86,7 @@ public class EvaluationContextImpl implements EvaluationContext {
for (EvaluationListener listener : configuration().getEvaluationListeners()) {
EvaluationListener.EvaluationContinuation continuation = listener.resultFound(new FoundResultImpl(idx, path, model));
if(EvaluationListener.EvaluationContinuation.ABORT == continuation){
throw new EvaluationAbortException();
throw ABORT_EVALUATION;
}
}
}

Loading…
Cancel
Save