Skip to content

Commit b6b79c4

Browse files
committed
Fix null pointer on invalid error response.
1 parent 68ead62 commit b6b79c4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

oauth/src/main/java/ch/cyberduck/core/oauth/OAuthExceptionMappingService.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ public BackgroundException map(final TokenResponseException failure) {
3838
final TokenErrorResponse details = failure.getDetails();
3939
if(null != details) {
4040
this.append(buffer, details.getErrorDescription());
41-
switch(details.getError()) {
42-
// Error code "invalid_request", "invalid_client", "invalid_grant", "unauthorized_client", "unsupported_grant_type", "invalid_scope"
43-
case "invalid_client":
44-
case "invalid_request":
45-
case "unauthorized_client":
46-
case "unsupported_grant_type":
47-
case "invalid_scope":
48-
return new LoginFailureException(buffer.toString(), failure);
49-
case "invalid_grant":
50-
return new ExpiredTokenException(buffer.toString(), failure);
41+
if(null != details.getError()) {
42+
switch(details.getError()) {
43+
// Error code "invalid_request", "invalid_client", "invalid_grant", "unauthorized_client", "unsupported_grant_type", "invalid_scope"
44+
case "invalid_client":
45+
case "invalid_request":
46+
case "unauthorized_client":
47+
case "unsupported_grant_type":
48+
case "invalid_scope":
49+
return new LoginFailureException(buffer.toString(), failure);
50+
case "invalid_grant":
51+
return new ExpiredTokenException(buffer.toString(), failure);
52+
}
5153
}
5254
}
5355
return new DefaultHttpResponseExceptionMappingService().map(new HttpResponseException(failure.getStatusCode(), buffer.toString()));

0 commit comments

Comments
 (0)