Skip to content

Commit 201590c

Browse files
committed
Merge remote-tracking branch 'origin/main' into rli/otel
2 parents eeb5b78 + 39c13ea commit 201590c

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Fix pointless busy loop in Amazon Q wasting CPU cycles (#5000)"
4+
}

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/ProjectContextProvider.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import kotlinx.coroutines.delay
2121
import kotlinx.coroutines.launch
2222
import kotlinx.coroutines.runBlocking
2323
import kotlinx.coroutines.withTimeout
24-
import kotlinx.coroutines.yield
2524
import software.aws.toolkits.core.utils.debug
2625
import software.aws.toolkits.core.utils.error
2726
import software.aws.toolkits.core.utils.getLogger
@@ -48,14 +47,15 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
4847
return@launch
4948
}
5049

50+
// TODO: need better solution for this
51+
@Suppress("LoopWithTooManyJumpStatements")
5152
while (true) {
5253
if (encoderServer.isNodeProcessRunning()) {
53-
// TODO: need better solution for this
5454
delay(10000)
5555
initAndIndex()
5656
break
5757
} else {
58-
yield()
58+
delay(10000)
5959
}
6060
}
6161
}

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/OpenedFileTypesMetrics.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class OpenedFileTypesMetricsService : Disposable {
5252
@Synchronized
5353
fun addToExistingTelemetryBatch(fileExt: String) {
5454
if (fileExt in ALLOWED_CODE_EXTENSIONS) {
55-
currentOpenedFileTypes.add(fileExt)
55+
val extension = ".$fileExt"
56+
currentOpenedFileTypes.add(extension)
5657
}
5758
}
5859

plugins/core/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/telemetry/OpenedFileTypeMetricsTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33

44
package software.aws.toolkits.jetbrains.services.telemetry
55

6-
import org.junit.After
7-
import org.junit.Before
8-
import org.junit.Test
9-
import org.mockito.kotlin.times
6+
import org.assertj.core.api.Assertions.assertThat
7+
import org.junit.jupiter.api.AfterEach
8+
import org.junit.jupiter.api.BeforeEach
9+
import org.junit.jupiter.api.Test
1010

1111
class OpenedFileTypeMetricsTest {
1212

1313
private lateinit var service: OpenedFileTypesMetricsService
1414

15-
@Before
15+
@BeforeEach
1616
fun setup() {
1717
service = OpenedFileTypesMetricsService()
1818
}
1919

20-
@After
20+
@AfterEach
2121
fun teardown() {
2222
service.dispose()
2323
}
2424

2525
@Test
2626
fun `test addToExistingTelemetryBatch with allowed extension`() {
2727
service.addToExistingTelemetryBatch("kt")
28-
assert(service.getOpenedFileTypes().contains("kt"))
28+
assertThat(service.getOpenedFileTypes()).contains(".kt")
2929
}
3030

3131
@Test
3232
fun `test addToExistingTelemetryBatch with disallowed extension`() {
3333
service.addToExistingTelemetryBatch("txt")
34-
assert(service.getOpenedFileTypes().isEmpty())
34+
assertThat(service.getOpenedFileTypes()).isEmpty()
3535
}
3636
}

0 commit comments

Comments
 (0)