Avoid request threads on AppEngine Java 8

While the code had correctly determined full threads were available, the
call to MoreExecutors returned a request thread factory, which has
limitations.

Note that Async stub users may not be able to call GAE APIs in
callbacks. This is because the threads aren't request threads. They can
override the individual call's executor with
com.google.appengine.api.ThreadManager.currentRequestThreadFactory() in
an interceptor via callOptions.withExecutor().

Fixes #3296
This commit is contained in:
Eric Anderson 2017-08-23 15:26:15 -07:00
parent 23dfc84ccf
commit 521c55e9bd
1 changed files with 1 additions and 3 deletions

View File

@ -482,12 +482,10 @@ public final class GrpcUtil {
* @return a {@link ThreadFactory}.
*/
public static ThreadFactory getThreadFactory(String nameFormat, boolean daemon) {
ThreadFactory threadFactory = MoreExecutors.platformThreadFactory();
if (IS_RESTRICTED_APPENGINE) {
return threadFactory;
return MoreExecutors.platformThreadFactory();
} else {
return new ThreadFactoryBuilder()
.setThreadFactory(threadFactory)
.setDaemon(daemon)
.setNameFormat(nameFormat)
.build();