很多情况会出现这中异常情况
java.lang.UnsupportedOperationException: null
at java.util.Collections$UnmodifiableList.sort(Collections.java:1331)
at java.util.Collections.sort(Collections.java:175)
at com.fyh.service.track.service.SQGpsDataQueryService.GPSsort(SQGpsDataQueryService.java:1067)
at com.fyh.service.track.service.SQGpsDataQueryService.findGPSData(SQGpsDataQueryService.java:902)
at com.fyh.service.track.controller.SQGpsDataController.findGPSData(SQGpsDataController.java:138)
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:209)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:870)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:776)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
... 57 common frames omitted
在我这里出现这种异常是调用了Collections.sort(list,new Comparator(xx){})访问对集合排序,抛出了异常。简答的来说就是说这个集合是不可变得。
然后在集合中我重新赋值定义
List newList = new ArrayList(oldList);
然后把新的list放进去即可