Skip to content

Commit b67dad7

Browse files
committed
Merge pull request #378 from ajkannan/reflection-fix
Fix code to get App Engine project ID
2 parents 6890fa1 + f3c8274 commit b67dad7

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,11 @@ protected static String getAppEngineProjectId() {
450450
try {
451451
Class<?> factoryClass =
452452
Class.forName("com.google.appengine.api.appidentity.AppIdentityServiceFactory");
453+
Class<?> serviceClass =
454+
Class.forName("com.google.appengine.api.appidentity.AppIdentityService");
453455
Method method = factoryClass.getMethod("getAppIdentityService");
454456
Object appIdentityService = method.invoke(null);
455-
method = appIdentityService.getClass().getMethod("getServiceAccountName");
457+
method = serviceClass.getMethod("getServiceAccountName");
456458
String serviceAccountName = (String) method.invoke(appIdentityService);
457459
int indexOfAtSign = serviceAccountName.indexOf('@');
458460
return serviceAccountName.substring(0, indexOfAtSign);

0 commit comments

Comments
 (0)