服务端如出现下面错误:
java.lang.NullPointerException at com.aliyuncs.DefaultAcsClient.readError(DefaultAcsClient.java:262) at com.aliyuncs.DefaultAcsClient.parseAcsResponse(DefaultAcsClient.java:166) at com.aliyuncs.DefaultAcsClient.getAcsResponse(DefaultAcsClient.java:106) at com.svw.avacar.push.service.impl.AliPushServiceImpl.push(AliPushServiceImpl.java:77) at com.svw.avacar.push.service.impl.AliPushServiceImpl$$FastClassBySpringCGLIB$$a269edd.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) at com.svw.avacar.push.aop.AliPushAspect.saveUserMessage(AliPushAspect.java:33) at sun.reflect.GeneratedMethodAccessor314.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673) at com.svw.avacar.push.service.impl.AliPushServiceImpl$$EnhancerBySpringCGLIB$$d77811a5.push() at com.svw.avacar.push.job.TimelyJob.execute(TimelyJob.java:61) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
原因是:IAcsClient 是线程安全的, 可以共用一个。
PushRequest 是线程不安全的,建议每次推送都 new 一个,即可解决。