9 RFR: 8178147: Race conditions in timeout handling code in http/2 incubator client

Pavel Rappo pavel.rappo at oracle.com
Thu Apr 6 12:28:23 UTC 2017


Heya Daniel,

    750     /**
    751      * same as above but for errors
    752      */
    753     void completeResponseExceptionally(Throwable t) {
    754         synchronized (response_cfs) {
    755             // use index to avoid ConcurrentModificationException
    756             // caused by removing the CF from within the loop.
    757             for (int i = 0; i < response_cfs.size(); i++) {
    758                 CompletableFuture<Response> cf = response_cfs.get(i);
    759                 if (!cf.isDone()) {
    760                     cf.completeExceptionally(t);
    761                     response_cfs.remove(i);
    762                     return;
    763                 }
    764             }
    765             response_cfs.add(MinimalFuture.failedFuture(t));
    766         }
    767     }

I was wondering if @762 should be there in the first place. The logic seems
a bit odd: find the first CF that hasn't been yet completed, complete it
and return. Are we guaranteed there are no other not-yet-completed CFs in
this list? Or we simply do not care about it?

Thanks.



More information about the net-dev mailing list