Scene:
Operation of the last result set list in paged query results add () or remove () operation, error: Java.lang.UnsupportedOperationException
Error:
java.lang.UnsupportedOperationException at Java.util.collections$unmodifiablecollection.add (Collections.java :1055) at Com.pisen.cloud.luna.ms.goods.api.impl.TenGoodsTypeApiImpl.pageFind (Tengoodstypeapiimpl.java:336) at com.pisen.cloud.luna.ms.goods.api.impl.tengoodstypeapiimpl$ $FastClassBySpringCGLIB $ $c 8d478cc.invoke ( <generated>) at Org.springframework.cglib.proxy.MethodProxy.invoke (Methodproxy.java:204) at Org.springframework.aop.framework.cglibaopproxy$cglibmethodinvocation.invokejoinpoint ( Cglibaopproxy.java:721) at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (Reflectivemethodinvocation.java: 157) at Org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed ( Methodinvocationproceedingjoinpoint.java:85) at Com.pisen.cloud.luna.core.aspects.LunaReqAspect.doAround (Lunareqaspect.java:41) 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:629) at Org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod (Abstractaspectjadvice.java: 31]) at Org.springframework.aop.aspectj.AspectJAroundAdvice.invoke (Aspectjaroundadvice.java:70) at Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (Reflectivemethodinvocation.java: 179) at Org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed ( Methodinvocationproceedingjoinpoint.java:85) at Com.pisen.cloud.luna.core.aspects.LunaValidAspect.doAround (Lunavalidaspect.java:184) at Com.pisen.cloud.luna.core.aspects.LunaValidAspect.doVerifyaAround (Lunavalidaspect.java:48) 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:629) at Org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod (Abstractaspectjadvice.java: 31]) 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: 656) at com.pisen.cloud.luna.ms.goods.api.impl.tengoodstypeapiimpl$ $EnhancerBySpringCGLIB $$5b3e2beb.pagefind ( <generated>) 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.web.method.support.InvocableHandlerMethod.doInvoke (Invocablehandlermethod.java: 205) at Org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest ( Invocablehandlermethod.java:133) at Org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle ( Servletinvocablehandlermethod.java:116) at Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod ( Requestmappinghandleradapter.java:827) at Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal ( Requestmappinghandleradapter.java:738) at Org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle ( Abstracthandlermethodadapter.java:85) at Org.springframework.web.servlet.DispatcherServlet.doDispatch (Dispatcherservlet.java:963) at Org.springframework.web.servlet.DispatcherServlet.doService (Dispatcherservlet.java:897) at Org.springframework.web.servlet.FrameworkServlet.processRequest (Frameworkservlet.java:970) at Org.springframework.web.servlet.FrameworkServlet.doGet (Frameworkservlet.java:861) at Javax.servlet.http.HttpServlet.service (Httpservlet.java:622) at Org.springframework.web.servlet.FrameworkServlet.service (Frameworkservlet.java:846) at Javax.servlet.http.HttpServlet.service (Httpservlet.java:729) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (Applicationfilterchain.java:230) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (Applicationfilterchain.java:165) at Org.apache.tomcat.websocket.server.WsFilter.doFilter (Wsfilter.java:52) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (Applicationfilterchain.java:192) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (Applicationfilterchain.java:165) at Org.springframework.web.filter.RequestContextFilter.doFilterInternal (Requestcontextfilter.java:99) at Org.springframework.web.filter.OncePerRequestFilter.doFilter (Onceperrequestfilter.java:107) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (Applicationfilterchain.java:192) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (Applicationfilterchain.java:165) at Org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal (Httpputformcontentfilter.java: 105) at Org.springframework.web.filter.OncePerRequestFilter.doFilter (Onceperrequestfilter.java:107) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (Applicationfilterchain.java:192) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (Applicationfilterchain.java:165) at Org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal (Hiddenhttpmethodfilter.java: 81) at Org.springframework.web.filter.OncePerRequestFilter.doFilter (Onceperrequestfilter.java:107) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (Applicationfilterchain.java:192) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (Applicationfilterchain.java:165) at Org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (Characterencodingfilter.java: 197) at Org.springframework.web.filter.OncePerRequestFilter.doFilter (Onceperrequestfilter.java:107) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (Applicationfilterchain.java:192) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (Applicationfilterchain.java:165) at Org.apache.catalina.core.StandardWrapperValve.invoke (Standardwrappervalve.java:198) at Org.apache.catalina.core.StandardContextValve.invoke (Standardcontextvalve.java:96) at Org.apache.catalina.authenticator.AuthenticatorBase.invoke (Authenticatorbase.java:474) at Org.apache.catalina.core.StandardHostValve.invoke (Standardhostvalve.java:140) at Org.apache.catalina.valves.ErrorReportValve.invoke (Errorreportvalve.java:79) at Org.apache.catalina.core.StandardEngineValve.invoke (Standardenginevalve.java:87) at Org.apache.catalina.connector.CoyoteAdapter.service (Coyoteadapter.java:349) at Org.apache.coyote.http11.Http11Processor.service (Http11processor.java:783) at Org.apache.coyote.AbstractProcessorLight.process (Abstractprocessorlight.java:66) at Org.apache.coyote.abstractprotocol$connectionhandler.process (Abstractprotocol.java:798) at Org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun (Nioendpoint.java:1434) at Org.apache.tomcat.util.net.SocketProcessorBase.run (Socketprocessorbase.java:49) at Java.util.concurrent.ThreadPoolExecutor.runWorker (Threadpoolexecutor.java:1149) at Java.util.concurrent.threadpoolexecutor$worker.run (Threadpoolexecutor.java:624) at Org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run (Taskthread.java:61) at Java.lang.Thread.run (Thread.java:748)
The error code is as follows:
As shown in the following code: After paged query comes out, directly to the result set list operation, only to report the above error
@Override PublicPageresult<goodstype>Pagefind (Goodstype entity) {Pageresult<GoodsType> res =NewPageresult<goodstype>(); Entity.initupdatedata (); Page<GoodsType> Findpage =Goodstypeservice.findpage (entity); Goodstype Goodstype=Goodstypeservice.get (Entity.getparentuid ()); List<GoodsType> list =findpage.getcontent (); if(Goodstype! =NULL) {list.add (goodstype); } res.inittrue (Findpage.gettotalelements (), list); returnRes; }
Workaround:
The result set is received using the new Arraylist<> (Findpage.getcontent ()).
The correct code is as follows:
@Override PublicPageresult<goodstype>Pagefind (Goodstype entity) {Pageresult<GoodsType> res =NewPageresult<goodstype>(); Entity.initupdatedata (); Page<GoodsType> Findpage =Goodstypeservice.findpage (entity); Goodstype Goodstype=Goodstypeservice.get (Entity.getparentuid ()); List<GoodsType> list =findpage.getcontent (); if(Goodstype! =NULL) { list = new Arraylist<> (list); List.add (Goodstype); } res.inittrue (Findpage.gettotalelements (), list); returnRes; }
"Java" operates on the final result set list in paged query results add () or remove () operation, error: Java.lang.UnsupportedOperationException