googleapis / googleapis/google-api-java-client

DefaultCredentialProvider should detect GAE Standard

未关闭
#1,231 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
priority: p4 type: feature request
主要语言
Java
星标
1.5k
派生
772
平均合并
1 小时 44 分钟
30 天内合并 PR
1

描述

This is the same issue as #1083, which has been fixed with #1109. However, the PR's changes but got reverted shortly after with #1123.

Now, I'm running into issues using the Cloud Endpoints framework on App Engine Standard with Java 8. I've registered a `ControlFilter` to publish API metrics to the Service Management API. This process uses the `DefaultCredentialProvider` to obtain credentials to authenticate against the Service Management API.
The flushing of these metrics will get executed in a different thread, so the error shown below (see stacktrace) is thrown. I would expect that no App Identity credential will be used in GAE Standard Java 8, instead the Metadata Server should be queried for a token (Compute Engine credential).

#### Environment details

- OS: App Engine Standard
- Java version: 8
- google-api-java-client version: 1.25.0

#### Steps to reproduce

1. Add `endpoints-management-control` library
2. Add a configured `ControlFilter` to the `EndpointsServlet`
3. Wait for the App Identity credential to be requested from memcache

#### Stacktrace

```
com.google.api.control.Client scheduleFlushes: scheduler com.google.api.control.Client@7d1da3d0 failed and exited (Client.java:304)
com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call memcache.Get in a thread that is neither the original request thread nor a thread created by ThreadManager at
com.google.apphosting.api.ApiProxy$CallNotFoundException.foreignThread(ApiProxy.java:844) at
com.google.apphosting.api.ApiProxy$1.get(ApiProxy.java:183) at
com.google.apphosting.api.ApiProxy$1.get(ApiProxy.java:180) at
com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:93) at
com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet(MemcacheServiceImpl.java:28) at
com.google.appengine.api.memcache.MemcacheServiceImpl.get(MemcacheServiceImpl.java:51) at
com.google.appengine.api.appidentity.AppIdentityServiceImpl.getAccessToken(AppIdentityServiceImpl.java:302) at
com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential.intercept(AppIdentityCredential.java:100) at
com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential$AppEngineCredentialWrapper.intercept(AppIdentityCredential.java:245) at
com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859) at
com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419) at
com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352) at
com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469) at
com.google.api.control.Client.flushAndScheduleReports(Client.java:397) at
com.google.api.control.Client.access$200(Client.java:61) at
com.google.api.control.Client$4.run(Client.java:416) at
com.google.api.control.Client$Scheduler.run(Client.java:765) at
com.google.api.control.Client$Scheduler.run(Client.java:775) at
com.google.api.control.Client.scheduleFlushes(Client.java:297) at
com.google.api.control.Client.access$000(Client.java:61) at
com.google.api.control.Client$2.run(Client.java:137) at
java.lang.Thread.run(Thread.java:745)

```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。