我注意到,当我们添加第一条路线时,spark-java框架会自动开始响应请求(添加第一条路线时,它会直接点燃码头)。
但是我们有很多路由,并且在加载所有路由期间,如果有请求到达,我们会在路由列表上收到ConcurrentModificationException。
是否有一种方法可以等到所有路由加载完毕后再响应任何请求?
ERROR 2019-04-08T10:18:32,243 spark.http.matching.GeneralError [qtp-1060778345-25]
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909) ~[?:1.8.0_202]
at java.util.ArrayList$Itr.next(ArrayList.java:859) ~[?:1.8.0_202]
at spark.route.Routes.findTargetsForRequestedRoute(Routes.java:201) ~[spark-core-2.7.2.jar:?]
at spark.route.Routes.find(Routes.java:84) ~[spark-core-2.7.2.jar:?]
at spark.http.matching.Routes.execute(Routes.java:34) ~[spark-core-2.7.2.jar:?]
at spark.http.matching.MatcherFilter.doFilter(MatcherFilter.java:130) [spark-core-2.7.2.jar:?]
at spark.embeddedserver.jetty.JettyHandler.doHandle(JettyHandler.java:50) [spark-core-2.7.2.jar:?]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1568) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.Server.handle(Server.java:530) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:347) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:256) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279) [jetty-io-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102) [jetty-io-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124) [jetty-io-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
at org.eclipse.jetty.util.thread.