Skip to content

Commit 8c9e9e1

Browse files
committed
cr
1 parent 03243a5 commit 8c9e9e1

File tree

1 file changed

+14
-6
lines changed
  • kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/conformance

1 file changed

+14
-6
lines changed

kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/conformance/ConformanceTest.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class ConformanceTest {
2222

2323
private var serverProcess: Process? = null
2424
private var serverPort: Int by Delegates.notNull()
25-
private val serverErrorOutput = StringBuffer()
25+
private val serverErrorOutput = mutableListOf<String>()
26+
private val maxErrorLines = 500
2627

2728
companion object {
2829
private val SERVER_SCENARIOS = listOf(
@@ -112,7 +113,12 @@ class ConformanceTest {
112113
try {
113114
BufferedReader(InputStreamReader(process.errorStream)).use { reader ->
114115
reader.lineSequence().forEach { line ->
115-
serverErrorOutput.appendLine(line)
116+
synchronized(serverErrorOutput) {
117+
if (serverErrorOutput.size >= maxErrorLines) {
118+
serverErrorOutput.removeAt(0)
119+
}
120+
serverErrorOutput.add(line)
121+
}
116122
logger.debug { "Server stderr: $line" }
117123
}
118124
}
@@ -128,10 +134,12 @@ class ConformanceTest {
128134
val serverReady = waitForServerReady(serverUrl)
129135

130136
if (!serverReady) {
131-
val errorInfo = if (serverErrorOutput.isNotEmpty()) {
132-
"\n\nServer error output:\n$serverErrorOutput"
133-
} else {
134-
""
137+
val errorInfo = synchronized(serverErrorOutput) {
138+
if (serverErrorOutput.isNotEmpty()) {
139+
"\n\nServer error output:\n${serverErrorOutput.joinToString("\n")}"
140+
} else {
141+
""
142+
}
135143
}
136144
serverProcess?.destroyForcibly()
137145
throw IllegalStateException(

0 commit comments

Comments
 (0)