You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Send multiple times by second request to the callback URL
Threads are blocked because of the ReentrantLock()
Code example
/** Lock on the flow. */privatefinalLocklock = newReentrantLock();
/** * Authorization code flow to be used across all HTTP servlet requests or {@code null} before * initialized in {@link #initializeFlow()}. */privateAuthorizationCodeFlowflow;
@OverrideprotectedfinalvoiddoGet(HttpServletRequestreq, HttpServletResponseresp)
throwsServletException, IOException {
StringBufferbuf = req.getRequestURL();
if (req.getQueryString() != null) {
buf.append('?').append(req.getQueryString());
}
AuthorizationCodeResponseUrlresponseUrl = newAuthorizationCodeResponseUrl(buf.toString());
Stringcode = responseUrl.getCode();
if (responseUrl.getError() != null) {
onError(req, resp, responseUrl);
} elseif (code == null) {
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
resp.getWriter().print("Missing authorization code");
} else {
lock.lock();
try {
if (flow == null) {
flow = initializeFlow();
}
StringredirectUri = getRedirectUri(req);
TokenResponseresponse = flow.newTokenRequest(code).setRedirectUri(redirectUri).execute();
StringuserId = getUserId(req);
Credentialcredential = flow.createAndStoreCredential(response, userId);
onSuccess(req, resp, credential);
} finally {
lock.unlock();
}
}
}
Any additional information below
If there are lots of requests, the Threads are blocked and waiting for the lock from other threads.
What the purpose of the lock? Is it onlyuseful for initializeFlow()?
Is the rest of the process thread safe?
The text was updated successfully, but these errors were encountered:
krog78
changed the title
google-oauth-java-client: AbstractCallBackServlet is blocked because of locks
google-oauth-java-client: AbstractAuthorizationCodeCallbackServletis blocked because of locks
Sep 25, 2023
krog78
changed the title
google-oauth-java-client: AbstractAuthorizationCodeCallbackServletis blocked because of locks
google-oauth-java-client: AbstractAuthorizationCodeCallbackServlet is blocked because of locks
Sep 25, 2023
Environment details
https://github.com/googleapis/google-oauth-java-client/blob/main/google-oauth-client-servlet/src/main/java/com/google/api/client/extensions/servlet/auth/oauth2/AbstractAuthorizationCodeCallbackServlet.java
Steps to reproduce
Code example
Any additional information below
If there are lots of requests, the Threads are blocked and waiting for the lock from other threads.
What the purpose of the lock? Is it onlyuseful for initializeFlow()?
Is the rest of the process thread safe?
Can we put
outside the lock?
Thanks
Regards,
Sylvain
The text was updated successfully, but these errors were encountered: