when I am handling a request I am acquiring a semaphore and releasing when complete.
Do I actually need to release at some other moment? Can complete not happen for some reason?
consider baseRequest of type org.eclipse.jetty.server.Request and _concurrencyGate of type Semaphore.
if (_concurrencyGate.tryAcquire(...)) {
var asyncContext = baseRequest.getAsyncContext();
asyncContext.addListener(new AsyncListener() {
@Override
public void onComplete(AsyncEvent event) {
_concurrencyGate.release();
}
@Override
public void onTimeout(AsyncEvent event) {\
}
@Override
public void onError(AsyncEvent event) {
}
@Override
public void onStartAsync(AsyncEvent event) {}
}, request, response);
}
}
onComplete() should be called at the end of every async cycle. If you observe otherwise, that would be something to take up with the vendor of the Servlet container you are using.
when I am handling a request I am acquiring a semaphore and releasing when complete. Do I actually need to release at some other moment? Can complete not happen for some reason? consider baseRequest of type org.eclipse.jetty.server.Request and _concurrencyGate of type Semaphore.