Fix compile warning
Change-Id: I36d32222e0898c6b45c7eae377458536b09704fd
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketApi.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketApi.java
index 52a9280..43b6e1a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketApi.java
@@ -94,11 +94,11 @@
if (response.getCode() == SC_OK) {
Token t = api.getAccessTokenExtractor().extract(response.getBody());
return new Token(t.getToken(), config.getApiSecret());
- } else {
- throw new OAuthException(
- String.format("Error response received: %s, HTTP status: %s",
- response.getBody(), response.getCode()));
}
+
+ throw new OAuthException(
+ String.format("Error response received: %s, HTTP status: %s",
+ response.getBody(), response.getCode()));
}
private String prepareAuthorizationHeaderValue() {
@@ -144,10 +144,10 @@
}
JsonElement accessToken = jsonObject.get(ACCESS_TOKEN);
return new Token(accessToken.getAsString(), "");
- } else {
- throw new OAuthException(
- String.format("Invalid JSON '%s': not a JSON Object", json));
}
+
+ throw new OAuthException(
+ String.format("Invalid JSON '%s': not a JSON Object", json));
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketOAuthService.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketOAuthService.java
index 80bbda4..d2240fc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketOAuthService.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketOAuthService.java
@@ -97,10 +97,10 @@
displayName == null || displayName.isJsonNull() ? null
: displayName.getAsString(),
null);
- } else {
- throw new IOException(
- String.format("Invalid JSON '%s': not a JSON Object", userJson));
}
+
+ throw new IOException(
+ String.format("Invalid JSON '%s': not a JSON Object", userJson));
}
@Override
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 2f92e72..04b9635 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/CasOAuthService.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/CasOAuthService.java
@@ -136,8 +136,7 @@
return new OAuthUserInfo(id.getAsString(), login, email, name, null);
}
- private String getStringElement(JsonObject o, String name)
- throws IOException {
+ private String getStringElement(JsonObject o, String name) {
JsonElement elem = o.get(name);
if (elem == null || elem.isJsonNull())
return null;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/GitHubOAuthService.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/GitHubOAuthService.java
index 7971b26..d66cd7f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/GitHubOAuthService.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/GitHubOAuthService.java
@@ -104,10 +104,10 @@
email == null || email.isJsonNull() ? null : email.getAsString(),
name == null || name.isJsonNull() ? null : name.getAsString(),
null);
- } else {
- throw new IOException(String.format(
- "Invalid JSON '%s': not a JSON Object", userJson));
}
+
+ throw new IOException(String.format(
+ "Invalid JSON '%s': not a JSON Object", userJson));
}
@Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/Google2Api.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/Google2Api.java
index 7874b7e..acdcfc5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/Google2Api.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/Google2Api.java
@@ -159,10 +159,10 @@
Matcher matcher = accessTokenPattern.matcher(response);
if (matcher.find()) {
return new Token(matcher.group(1), "", response);
- } else {
- throw new OAuthException(
- "Cannot extract an acces token. Response was: " + response);
}
+
+ throw new OAuthException(
+ "Cannot extract an acces token. Response was: " + response);
}
}
}
\ No newline at end of file
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/GoogleOAuthService.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/GoogleOAuthService.java
index b051bad..860f34b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/GoogleOAuthService.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/GoogleOAuthService.java
@@ -151,10 +151,10 @@
email == null || email.isJsonNull() ? null : email.getAsString() /*email*/,
name == null || name.isJsonNull() ? null : name.getAsString() /*displayName*/,
claimedIdentifier /*claimedIdentity*/);
- } else {
- throw new IOException(String.format(
- "Invalid JSON '%s': not a JSON Object", userJson));
}
+
+ throw new IOException(String.format(
+ "Invalid JSON '%s': not a JSON Object", userJson));
}
private JsonObject retrieveJWTToken(OAuthToken token) {