Skip to content

Commit

Permalink
Prevent multiple invocations of generateUserProfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
Attacktive committed May 23, 2022
1 parent 2f599bb commit 8306d92
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/kotlin/app/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ object UserService {
}

fun getUserProfile(username: String): UserProfile {
return (CacheService.lookUpInCache(username) ?: generateUserProfile(username))
synchronized(username) {
return (CacheService.lookUpInCache(username) ?: generateUserProfile(username))
}
}

private fun hasStarredRepo(username: String): Boolean {
Expand Down

0 comments on commit 8306d92

Please sign in to comment.