Merge branch 'stable-3.1'
* stable-3.1:
Upgrade bazlets to latest stable-3.1 to build with 3.1.6 API
Upgrade bazlets to latest stable-3.0 to build with 3.0.10 API
Upgrade bazlets to latest stable-2.16 to build with 2.16.21 API
Upgrade bazlets to latest stable-2.15 to build with 2.15.19 API
Upgrade bazlets to latest stable-2.14 to build with 2.14.21 API
Prevent NPE in Cas service
Change-Id: I4b67b79980d324f28ed0306fc031958c1b37a457
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/CasOAuthService.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/CasOAuthService.java
index d76769a..5f3e4a1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/CasOAuthService.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/CasOAuthService.java
@@ -15,6 +15,7 @@
package com.googlesource.gerrit.plugins.oauth;
import static com.google.gerrit.json.OutputFormat.JSON;
+import static com.google.common.base.Strings.nullToEmpty;
import com.github.scribejava.core.builder.ServiceBuilder;
import com.github.scribejava.core.model.OAuth2AccessToken;
@@ -159,7 +160,9 @@
try {
OAuth2AccessToken accessToken = service.getAccessToken(rv.getValue());
return new OAuthToken(
- accessToken.getAccessToken(), accessToken.getTokenType(), accessToken.getRawResponse());
+ accessToken.getAccessToken(),
+ nullToEmpty(accessToken.getTokenType()),
+ accessToken.getRawResponse());
} catch (InterruptedException | ExecutionException | IOException e) {
String msg = "Cannot retrieve access token";
log.error(msg, e);