Skip to content

Commit

Permalink
fix spel compiler mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
areyouok committed Dec 26, 2019
1 parent 9a3ceba commit 8382527
Showing 1 changed file with 1 addition and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
package com.alicp.jetcache.anno.method;

import com.alicp.jetcache.CacheConfigException;
import com.alicp.jetcache.CacheException;
import org.mvel2.MVEL;
import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.function.Function;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -94,22 +91,7 @@ class SpelEvaluator implements Function<Object, Object> {
private static ParameterNameDiscoverer parameterNameDiscoverer;

static {
try {
//since spring 4.1
Class modeClass = Class.forName("org.springframework.expression.spel.SpelCompilerMode");

try {
Constructor<SpelParserConfiguration> c = SpelParserConfiguration.class
.getConstructor(modeClass, ClassLoader.class);
Object mode = modeClass.getField("IMMEDIATE").get(null);
SpelParserConfiguration config = c.newInstance(mode, SpelEvaluator.class.getClassLoader());
parser = new SpelExpressionParser(config);
} catch (Exception e) {
throw new CacheException(e);
}
} catch (ClassNotFoundException e) {
parser = new SpelExpressionParser();
}
parser = new SpelExpressionParser();
parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
}

Expand Down

0 comments on commit 8382527

Please sign in to comment.