diff --git a/api_dev/src/main/java/com/google/appengine/tools/development/ApiProxyLocalImpl.java b/api_dev/src/main/java/com/google/appengine/tools/development/ApiProxyLocalImpl.java index 900727db..9304d3b1 100644 --- a/api_dev/src/main/java/com/google/appengine/tools/development/ApiProxyLocalImpl.java +++ b/api_dev/src/main/java/com/google/appengine/tools/development/ApiProxyLocalImpl.java @@ -203,10 +203,12 @@ public Future makeAsyncCall( Semaphore semaphore = (Semaphore) environment.getAttributes().get( LocalEnvironment.API_CALL_SEMAPHORE); if (semaphore != null) { - // TODO: investigate why the acquire() locks when Sessions are configured in appengine-web.xml - // Maybe the semaphore has been released just before the app engine session manager starts - // saving the data in datastore. - semaphore.tryAcquire(); + try { + semaphore.acquire(); + } catch (InterruptedException ex) { + // We never do this, so just propagate it as a RuntimeException for now. + throw new RuntimeException("Interrupted while waiting on semaphore:", ex); + } } AsyncApiCall asyncApiCall = new AsyncApiCall(environment, packageName, methodName, requestBytes, semaphore); diff --git a/pom.xml b/pom.xml index 5c9bef72..ed3fb28a 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 1.8 UTF-8 9.4.53.v20231009 - 12.0.2 + 12.0.3 2.0.9 https://oss.sonatype.org/content/repositories/google-snapshots/ sonatype-nexus-snapshots diff --git a/runtime/local_jetty12_ee10/src/main/java/com/google/appengine/tools/development/jetty/ee10/JettyContainerService.java b/runtime/local_jetty12_ee10/src/main/java/com/google/appengine/tools/development/jetty/ee10/JettyContainerService.java index 38660b73..b20ae2e9 100644 --- a/runtime/local_jetty12_ee10/src/main/java/com/google/appengine/tools/development/jetty/ee10/JettyContainerService.java +++ b/runtime/local_jetty12_ee10/src/main/java/com/google/appengine/tools/development/jetty/ee10/JettyContainerService.java @@ -57,6 +57,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; @@ -70,6 +71,7 @@ import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; +import org.eclipse.jetty.server.HttpStream; import org.eclipse.jetty.server.NetworkTrafficServerConnector; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Response; @@ -626,7 +628,20 @@ public boolean handle(Request request, Response response, Callback callback) thr // this and so the Environment has not yet been created. ApiProxy.Environment oldEnv = enterScope(request); try { - callback = Callback.from(callback, () -> onComplete(contextRequest)); + request.addHttpStreamWrapper(s -> new HttpStream.Wrapper(s) + { + @Override + public void succeeded() { + onComplete(contextRequest); + super.succeeded(); + } + + @Override + public void failed(Throwable x) { + onComplete(contextRequest); + super.failed(x); + } + }); return super.handle(request, response, callback); } finally {