全部产品
云市场
云游戏
    推送时偶现 java.lang.NullPointerException 错误

推送时偶现 java.lang.NullPointerException 错误

更新时间:2020-08-06 14:42:39

服务端如出现下面错误:

  1. java.lang.NullPointerException
  2. at com.aliyuncs.DefaultAcsClient.readError(DefaultAcsClient.java:262)
  3. at com.aliyuncs.DefaultAcsClient.parseAcsResponse(DefaultAcsClient.java:166)
  4. at com.aliyuncs.DefaultAcsClient.getAcsResponse(DefaultAcsClient.java:106)
  5. at com.svw.avacar.push.service.impl.AliPushServiceImpl.push(AliPushServiceImpl.java:77)
  6. at com.svw.avacar.push.service.impl.AliPushServiceImpl$$FastClassBySpringCGLIB$$a269edd.invoke()
  7. at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
  8. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
  9. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
  10. at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62)
  11. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
  12. at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
  13. at com.svw.avacar.push.aop.AliPushAspect.saveUserMessage(AliPushAspect.java:33)
  14. at sun.reflect.GeneratedMethodAccessor314.invoke(Unknown Source)
  15. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  16. at java.lang.reflect.Method.invoke(Method.java:498)
  17. at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
  18. at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
  19. at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
  20. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  21. at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
  22. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  23. at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
  24. at com.svw.avacar.push.service.impl.AliPushServiceImpl$$EnhancerBySpringCGLIB$$d77811a5.push()
  25. at com.svw.avacar.push.job.TimelyJob.execute(TimelyJob.java:61)
  26. at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
  27. at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

原因是:IAcsClient 是线程安全的, 可以共用一个。

PushRequest 是线程不安全的,建议每次推送都 new 一个,即可解决。