项目在做高并发测试的时候,出现了异常如下,由于加密解密频繁
解决办法:将已经实例化的Cipher对象,放在hashmap中,每次实例化的时候从MAP 获取,不存在的时候再进行实例化,问题解决。
2018-07-07 10:45:39.543 DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession
2018-07-07 10:45:39.544 DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1dce97a4] was not registered for synchronization because synchronization is not active
2018-07-07 10:45:39.544 DEBUG org.mybatis.spring.transaction.SpringManagedTransaction - JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@2e065a9e] will not be managed by Spring
2018-07-07 10:45:39.544 DEBUG com.jufengad.insurance.server.dao.InsuranceCategoryMapper.queryPageByparams - ==> Preparing: SELECT id, unique_code, parent_id, parent_code, category_name, description, category_key, category_level,pic_path, status, create_time, create_person from insurance_category where 1 = 1 order by category_level asc
2018-07-07 10:45:39.545 DEBUG com.jufengad.insurance.server.dao.InsuranceCategoryMapper.queryPageByparams - ==> Parameters:
七月 07, 2018 10:45:39 上午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [insurance_server_servlet] in context with path [/insurance-server] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Cipher not initialized] with root cause
java.lang.IllegalStateException: Cipher not initialized
at javax.crypto.Cipher.checkCipherState(Cipher.java:1749)
at javax.crypto.Cipher.doFinal(Cipher.java:2156)
at com.jufengad.insurance.server.util.SecurityUtil.encrypt(SecurityUtil.java:88)
at com.jufengad.insurance.server.util.SecurityUtil.getSecretKey(SecurityUtil.java:67)
at com.jufengad.insurance.server.factory.impl.SimpleDtoFactory.getSecretKey(SimpleDtoFactory.java:54)
at com.jufengad.insurance.server.factory.impl.SimpleDtoFactory.createResponse(SimpleDtoFactory.java:87)
at com.jufengad.insurance.server.factory.impl.SimpleDtoFactory.createAdminResponse(SimpleDtoFactory.java:72)
at com.jufengad.insurance.server.controller.product.ProductController.queryProductPage(ProductController.java:96)
at com.jufengad.insurance.server.controller.product.ProductController$$FastClassBySpringCGLIB$$c19c8976.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:711)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
at com.jufengad.insurance.server.aop.ControllerLogAspect.doAroundMethod(ControllerLogAspect.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
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:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)