Skip to content

Instantly share code, notes, and snippets.

@joshuakfarrar
Created June 23, 2014 20:55
Show Gist options
  • Save joshuakfarrar/100c28240daf014094c8 to your computer and use it in GitHub Desktop.
Save joshuakfarrar/100c28240daf014094c8 to your computer and use it in GitHub Desktop.
@Override
public UserRefreshResult call() throws InterruptedException {
try {
checkCacheForUser();
} catch (UserNotCachedException e) {
tryCachingUser();
} catch (ApiRequestForUserAlreadyStartedException e) {
logger.warn("There is already a registration in progress, ignoring");
return UserRefreshResult.IN_PROGRESS;
}
...
}
private void checkCacheForUser() {
if (isUserCached()) {
return;
} else if (isRegistrationAlreadyStarted()) {
throw new ApiRequestForUserAlreadyStartedException();
} else {
throw new UserNotCachedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment