Skip to content

Commit 1301bfd

Browse files
committed
Avoid blocking in an async context
1 parent c02667e commit 1301bfd

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

service/src/main/java/org/whispersystems/textsecuregcm/auth/PhoneVerificationTokenManager.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,24 @@ private void verifyBySessionId(final String number, final byte[] sessionId) thro
108108
}
109109
}
110110

111-
private void verifyByRecoveryPassword(final ContainerRequestContext requestContext, final String number, final byte[] recoveryPassword)
112-
throws InterruptedException {
111+
private void verifyByRecoveryPassword(final ContainerRequestContext requestContext,
112+
final String number,
113+
final byte[] recoveryPassword) throws InterruptedException {
114+
113115
if (!registrationRecoveryChecker.checkRegistrationRecoveryAttempt(requestContext, number)) {
114116
throw new ForbiddenException("recoveryPassword couldn't be verified");
115117
}
118+
116119
try {
117-
final boolean verified = registrationRecoveryPasswordsManager.verify(phoneNumberIdentifiers.getPhoneNumberIdentifier(number).join(), recoveryPassword)
120+
final boolean verified = phoneNumberIdentifiers.getPhoneNumberIdentifier(number)
121+
.thenCompose(phoneNumberIdentifier -> registrationRecoveryPasswordsManager.verify(phoneNumberIdentifier, recoveryPassword))
118122
.get(VERIFICATION_TIMEOUT_SECONDS, TimeUnit.SECONDS);
123+
119124
if (!verified) {
120125
throw new ForbiddenException("recoveryPassword couldn't be verified");
121126
}
122127
} catch (final ExecutionException | TimeoutException e) {
123128
throw new ServerErrorException(Response.Status.SERVICE_UNAVAILABLE);
124129
}
125130
}
126-
127131
}

0 commit comments

Comments
 (0)