Skip to content

Commit

Permalink
Add a system property ("appengine.ignore.cancelerror") to ignore CANC…
Browse files Browse the repository at this point in the history
…ELLED errors from the API proxy. See #279

PiperOrigin-RevId: 681616924
Change-Id: Icc1cebe0c506e66bbde5a3b83b2ad5004c82d11f
  • Loading branch information
ludoch authored and gae-java-bot committed Oct 2, 2024
1 parent 55f9395 commit 78bbabe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void handleRuntimeProperties() {
// See if the Mendel experiment to enable HttpConnector is set automatically via env var:
if (Objects.equals(System.getenv("EXPERIMENT_ENABLE_HTTP_CONNECTOR_FOR_JAVA"), "true")
&& !Objects.equals(System.getenv("GAE_RUNTIME"), "java8")) {
System.setProperty("appengine.ignore.cancelerror", "true");
System.setProperty("appengine.use.HttpConnector", "true");
}
try (final InputStream stream = new FileInputStream(file)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.google.apphosting.runtime;

import static com.google.apphosting.base.protos.RuntimePb.APIResponse.ERROR.CANCELLED;

import com.google.appengine.tools.development.TimedFuture;
import com.google.apphosting.api.ApiProxy;
import com.google.apphosting.api.ApiProxy.ApiResultFuture;
Expand Down Expand Up @@ -687,8 +689,13 @@ public void success(APIResponse response) {
}
settable.set(apiResponse.getPb().toByteArray());
} else {
settable.setException(
ApiProxyUtils.getApiError(packageName, methodName, apiResponse, logger));
if ((APIResponse.ERROR.forNumber(apiResponse.getError()) == CANCELLED)
&& Boolean.getBoolean("appengine.ignore.cancelerror")) {
settable.set(apiResponse.getPb().toByteArray());
} else {
settable.setException(
ApiProxyUtils.getApiError(packageName, methodName, apiResponse, logger));
}
}
environment.removeAsyncFuture(this);
}
Expand Down Expand Up @@ -1281,9 +1288,7 @@ public TraceExceptionGenerator getTraceExceptionGenerator() {
}
}

/**
* A thread created by {@code ThreadManager.currentRequestThreadFactory().
*/
/** A thread created by {@code ThreadManager.currentRequestThreadFactory()}. */
public static class CurrentRequestThread extends Thread {
private final Runnable userRunnable;
private final RequestState requestState;
Expand Down

0 comments on commit 78bbabe

Please sign in to comment.