Skip to content

Commit d79579c

Browse files
author
Ulrike Kiesel
committed
fix(analysis): replace fixed sleep with polling in ProjectInputReader
The fixed 100ms sleep was insufficient on CI after the TreeSitter v0.4.1 dependency bump (1.5 MB JAR), which slightly increased JVM startup time. The upstream svnlogparser process no longer wrote its sync flag within 100ms, so modify read an empty stdin and skipped writing the output file. Replace with a polling loop (50ms interval, 500ms max) that exits as soon as data is available, making the pipe chain robust to JVM startup variance.
1 parent cb15e6a commit d79579c

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

analysis/model/src/main/kotlin/de/maibornwolff/codecharta/serialization/ProjectInputReader.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,24 @@ import java.io.InputStreamReader
88
import java.util.Scanner
99

1010
object ProjectInputReader {
11-
/**
11+
private const val MAX_WAIT_MS = 500L
12+
private const val CHECK_INTERVAL_MS = 50L
13+
14+
/**
1215
* Extracts a JSON string representing a project from the given InputStream.
1316
* Because piped bash commands run concurrently, a pipeable ccsh-parser sends a sync flag
1417
* to signal other parsers to check for piped input.
15-
* A short wait ensures the availability of potential sync flags.
18+
* Polls for data availability to handle concurrent JVM startup delays.
1619
*
1720
* @param input InputStream with serialized project data.
1821
* @return JSON string of the project, or an empty string if no valid data is found.
1922
*/
2023
fun extractProjectString(input: InputStream): String {
21-
Thread.sleep(100)
24+
var waited = 0L
25+
while (input.available() <= 0 && waited < MAX_WAIT_MS) {
26+
Thread.sleep(CHECK_INTERVAL_MS)
27+
waited += CHECK_INTERVAL_MS
28+
}
2229
val availableBytes = input.available()
2330
if (availableBytes <= 0) {
2431
return ""

0 commit comments

Comments
 (0)