PlayFramework 2.5 - Execution exception[[CompletionException: java.util.ConcurrentModificationException: java.util.ConcurrentModificationException]]

349 views
Skip to first unread message

404NotFound

unread,
Apr 1, 2017, 6:13:57 PM4/1/17
to Play Framework
When I am sending HTTP requests to play controller faster then usually, I am getting this error:

Execution exception[[CompletionException: java.util.ConcurrentModificationException: java.util.ConcurrentModificationException]]

Its happening in this part of code:

this.points=layer.points!=null ? layer.points.parallelStream().map(point -> new FPoint(point,messages)).collect(Collectors.toList()) : new ArrayList<>();

Whole stack:

play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[CompletionException: java.util.ConcurrentModificationException: java.util.ConcurrentModificationException]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:280)
at play.api.http.HttpErrorHandlerExceptions.throwableToUsefulException(HttpErrorHandler.scala)
at play.http.DefaultHttpErrorHandler.throwableToUsefulException(DefaultHttpErrorHandler.java:169)
at play.http.DefaultHttpErrorHandler.onServerError(DefaultHttpErrorHandler.java:131)
at play.core.j.JavaHttpErrorHandlerAdapter$$anonfun$onServerError$1.apply(JavaHttpErrorHandlerAdapter.scala:22)
at play.core.j.JavaHttpErrorHandlerAdapter$$anonfun$onServerError$1.apply(JavaHttpErrorHandlerAdapter.scala:22)
at play.core.j.JavaHelpers$$anonfun$invokeWithContext$1.apply(JavaHelpers.scala:142)
at play.core.j.JavaHelpers$$anonfun$invokeWithContext$1.apply(JavaHelpers.scala:141)
at play.core.j.JavaHelpers$class.withContext(JavaHelpers.scala:153)
at play.core.j.JavaHelpers$.withContext(JavaHelpers.scala:162)
Caused by: java.util.concurrent.CompletionException: java.util.ConcurrentModificationException: java.util.ConcurrentModificationException
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:593)
at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:21)
at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:18)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
at scala.concurrent.BatchingExecutor$Batch$$anonfun$run$1.processBatch$1(BatchingExecutor.scala:63)
Caused by: java.util.ConcurrentModificationException: java.util.ConcurrentModificationException
at sun.reflect.GeneratedConstructorAccessor78.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)
at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)
at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:735)
at java.util.stream.ReduceOps$ReduceOp.evaluateParallel(ReduceOps.java:714)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at controllers.liek.api.results.TLayer.<init>(TLayer.java:195)
Caused by: java.util.ConcurrentModificationException: null
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
at java.util.ArrayList$Itr.next(ArrayList.java:851)
at com.avaje.ebean.common.ModifyIterator.next(ModifyIterator.java:39)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:747)
at java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:721)
at java.util.stream.AbstractTask.compute(AbstractTask.java:316)

As ORM I am using Ebean. There is no modification with update , or insert happening in this part of code only selects.
Controller looks like this:

 @BodyParser.Of(BodyParser.Json.class)
 
@Transactional
    
public Result getLayerByID(){
        
Messages messages=messagesApi.preferred(request());
        
Form<FInputData> search=formFactory.form(FInputData.class).bindFromRequest();
        
if (search.hasErrors()) {
            
return badRequest(search.errorsAsJson());
        
}
        
FSearchData fSearchData = search.get();
        
User actualUser = userService.actualUser(ctx());
        
Result res=null;
        
if (fSearchData !=null) {
            result
=layerService.findByID(fSearchData.ID);
        
}
        
if (result==null) {
                
return badRequest(Json.toJson(new TAction(messages.at("layer.doesNotExists",fSearchData.ID))));
        
}
        
TLayer tResult=result!=null ? new TLayer(result,actualUser ,messages) : null;
        
return ok(Json.toJson(tResult!=null ?  tResult : new TEmpty() ));
    
}



layerService.findByID(..) is actually making 20+ selects to database. Where could be problem?

I am using 
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.1.0")
which should support JAVA8 streams...

404NotFound

unread,
Apr 1, 2017, 6:22:54 PM4/1/17
to Play Framework
Also I am getting other strange errors like:

Caused by: java.util.concurrent.CompletionException: javax.persistence.EntityNotFoundException: Lazy loading failed on type:models.PointOfInterest id:25 - Bean has been deleted

 when spam clicking to call other controller. And on next request there is no such error and then randomly on next request there is this error , while parameters for all requests are same and no other request has been made between them (its on developing machine)

404NotFound

unread,
Apr 1, 2017, 6:38:38 PM4/1/17
to Play Framework
All these errors are ocurring randomly and only when spaming request to controller

All these errors are ocurring randomly and only when spaming request to controller

All these errors are ocurring randomly and only when spaming request to controller


All these errors are ocurring randomly and only when spaming request to controller

All these errors are ocurring randomly and only when spaming request to controller

All these errors are ocurring randomly and only when spaming request to controller 

404NotFound

unread,
Apr 1, 2017, 7:30:10 PM4/1/17
to Play Framework
I have rewritten all ".parallelStream()" back to java7 loops and these errors does not occur anymore. So there is some problem with java8 implementation (probably in ebean.)

Greg Methvin

unread,
Apr 2, 2017, 2:46:27 AM4/2/17
to Play Framework
Yeah, from looking at it originally it didn't seem like a Play issue. You might want to ask on the Ebean mailing list: https://groups.google.com/forum/#!forum/ebean

Greg
_____________________________
From: 404NotFound <oby...@gmail.com>
Sent: Saturday, April 1, 2017 16:30
Subject: [play-framework] Re: PlayFramework 2.5 - Execution exception[[CompletionException: java.util.ConcurrentModificationException: java.util.ConcurrentModificationException]]
To: Play Framework <play-fr...@googlegroups.com>



I have rewritten all ".parallelStream()" back to java7 loops and these errors does not occur anymore. So there is some problem with java8 implementation (probably in ebean.)

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/298d2ddb-1ee5-4131-89bc-3c3bab2fcca2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


alex s

unread,
Apr 2, 2017, 5:30:53 AM4/2/17
to Play Framework
воскресенье, 2 апреля 2017 г., 2:30:10 UTC+3 пользователь 404NotFound написал:
I have rewritten all ".parallelStream()" back to java7 loops and these errors does not occur anymore.
Reply all
Reply to author
Forward
0 new messages