forezp / distributed-limit

一个分布式限流的解决方案!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KeyUtil.getKey() 里面 limitEntity.getLimitType() 空指针异常

hyede opened this issue · comments

commented

java.lang.NullPointerException: null
at io.github.forezp.distributedlimitcore.util.KeyUtil.getKey(KeyUtil.java:20) ~[distributed-limit-core-1.0.4.jar:na]
at io.github.forezp.distributedlimitcore.limit.RedisLimitExcutor.tryAccess(RedisLimitExcutor.java:43) ~[distributed-limit-core-1.0.4.jar:na]
at io.github.forezp.distributedlimitcore.aop.LimitAop.before(LimitAop.java:77) ~[distributed-limit-core-1.0.4.jar:na]
at sun.reflect.GeneratedMethodAccessor526.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45005) ~[na:1.8.0_112]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_112]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) ~[spring-aop-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:626) ~[spring-aop-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.aop.aspectj.AspectJMethodBeforeAdvice.before(AspectJMethodBeforeAdvice.java:44) ~[spring-aop-5.0.5.RELEASE.jar:5.0.5.RELEASE]

commented

limit.type = redis/local 你需要在配置文件一下

已经在配置文件配置了,但还是报了空指针异常

解决了吗

已经在配置文件配置了,但还是报了空指针异常

同遇到

我也遇到了这个问题, 通过查看官方的example,发现需要在配置文件中指定限制规则 ;

limit.filter=true
limit.rule.url.num=100
limit.rule.url.seconds=2
limit.rule.identifier.key=userId

上面会按照url的规则来拦截 ,希望能够提供一个默认的拦截方式,否则如果不配置会出现上面的NPE问题