File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/service Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ import java.util.concurrent.TimeUnit
90
90
91
91
@Service
92
92
class CodeWhispererService {
93
+ private var refreshFailure: Int = 0
94
+
93
95
fun showRecommendationsInPopup (
94
96
editor : Editor ,
95
97
triggerTypeInfo : TriggerTypeInfo ,
@@ -106,10 +108,18 @@ class CodeWhispererService {
106
108
}
107
109
108
110
if (isQExpired(project)) {
109
- // The purpose to execute in the background is to hide the progress indicator UI
110
- val shouldReauth = ApplicationManager .getApplication().executeOnPooledThread<Boolean > {
111
- promptReAuth(project)
112
- }.get()
111
+ // say the connection is un-refreshable if refresh fails for 3 times
112
+ val shouldReauth = if (refreshFailure < MAX_REFRESH_ATTEMPT ) {
113
+ ApplicationManager .getApplication().executeOnPooledThread<Boolean > {
114
+ promptReAuth(project)
115
+ }.get().also { success ->
116
+ if (! success) {
117
+ refreshFailure++
118
+ }
119
+ }
120
+ } else {
121
+ true
122
+ }
113
123
114
124
if (shouldReauth) {
115
125
return
@@ -754,6 +764,8 @@ class CodeWhispererService {
754
764
755
765
companion object {
756
766
private val LOG = getLogger<CodeWhispererService >()
767
+ private const val MAX_REFRESH_ATTEMPT = 3
768
+
757
769
val CODEWHISPERER_CODE_COMPLETION_PERFORMED : Topic <CodeWhispererCodeCompletionServiceListener > = Topic .create(
758
770
" CodeWhisperer code completion service invoked" ,
759
771
CodeWhispererCodeCompletionServiceListener ::class .java
You can’t perform that action at this time.
0 commit comments